Function String Replacements Class

StripNilCharacterForward

Strips the first Nil character (Chr$(0); the character whose ASCII value is 0 (zero)) and all following characters from a string.

Signature (Visual Basic / VBA)

Public Function StripNilCharacterForward( _
    ByVal vLine As Variant _
    ) As Variant

Code Example

    Assuming
       Dim S As String
       S = String$(128, 0)
       Mid$(S, 1, 4) = "Test"
    for example
       S = StripNilCharacterForward(S)
    leaves
       S = "Test"

Parameters

Parameter Description
vLine The string whose trailing nil-terminated portion is to be removed. Function returns Null if vLine is Null or cannot be fixed up to a String (Behavior #1).

Return Value

Function returns the string unchanged if it does not contain any Nil characters (Behavior #2).

Notes & Version History

Note This function is usually used to convert fixed-length nil-terminated C strings into variable-length Visual Basic strings after the string has had its value assigned as the result of a call to an API function.