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
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.