CodeItBetter Programming Another VB Programming Blog

How to Strip the Null Terminator from a given String

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'String Manipulation - How to Strip the Null Terminator from a given String
Option Explicit
 
Public Function StripNull(ByVal sExpression As String) As String
 
'Input: String containing null terminator ( chr ( 0 ) )
'Returns: all character before the null terminator

    Dim iNullChar As Integer
    If Len(sExpression) > 0 Then
        iNullChar = InStr(sExpression, vbNullChar)
        Select Case iNullChar
        Case 0
            StripNull = sExpression
        Case 1
            StripNull = ""
        Case Else
            StripNull = Left$(sExpression, iNullChar - 1)
        End Select
    End If
End Function

Related posts:

  1. How to Strip/Remove Text from a given String
  2. How to Strip special characters from a given String
  3. How to Strip Numeric from a string
  4. How to Strip Alphabets from a string
  5. How to check whether given string is numeric or not without using IsNumeric function.
  6. How to Remove all Non Alpha Numeric characters from a given string
  7. How to Strip Non Alpha Numeric from a string
  8. How to check if a string contains only Alphabetical Characters
  9. How to check if a string contains only Numeric Characters
  10. How to return everything between ’string2′ in ’string1′

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.