• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Visual Basic Strip the Null Terminator from a String

Status
Not open for further replies.

Kaway

Banned
User
Joined
Aug 7, 2014
Messages
720
Reputation
0
Reaction score
5,766
Points
243
Credits
0
‎10 Years of Service‎
15%
Please note, if you want to make a deal with this user, that it is blocked.
[HIDE-THANKS]For many API functions, you have to pass a space-padded string to the function and strip the null terminator from value returned. This is the purpose of this snippet.

Code:
>Public Function StripNull(ByVal InString As String) As String

'Input: String containing null terminator (Chr(0))
'Returns: all character before the null terminator

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

End Function
[/HIDE-THANKS]

 
Status
Not open for further replies.
Back
Top