Results 1 to 5 of 5

Thread: Stripnulls Explanation

  1. #1

    Thread Starter
    Hyperactive Member Knowledge_is_Et's Avatar
    Join Date
    Dec 2001
    Location
    An Oak.
    Posts
    305

    Stripnulls Explanation

    VB Code:
    1. Function StripNulls(OriginalStr As String) As String
    2. If (InStr(OriginalStr, Chr(0)) > 0) Then
    3. OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
    4. End If
    5. StripNulls = OriginalStr
    6. End Function

    Ok, I know what that does, but I'm not so familiar with string functions, so... how does it work... and why do I get nulls from c++ but I can't add nulls to a string? like:

    VB Code:
    1. for I = 0 to 10
    2. stringname = stringname & null (or vbNull?)
    3. next i
    Last edited by Knowledge_is_Et; Sep 8th, 2002 at 10:47 PM.
    Now returning to the world of VB. Please make sure your seatbelts are securely fastened and all trays are in their upright and locked position.

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    adding vbNull to the end of the string should add a null character to it. If it doesn't work, you can always use Chr(0), which is the ASCII for null. That StripNulls function looks like it is cutting off the whole string after the first null it incounters.
    <removed by admin>

  3. #3
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724

    Re: Stripnulls Explanation


    VB Code:
    1. for I = 0 to 10
    2. stringname = stringname & null (or vbNull?)
    3. next i
    [/B]
    if the stringname is a string datatype how will it help u cannot add null to string variables.

    if u need blank spaces u can use " " or space() function

  4. #4

    Thread Starter
    Hyperactive Member Knowledge_is_Et's Avatar
    Join Date
    Dec 2001
    Location
    An Oak.
    Posts
    305
    No, I was just trying that to see if a function worked, but it seemed to never add the nulls, and I was wondering why VB (if it won't let me add nulls) was just cutting them of, in which case why it wouldn't do it when returned from a API.

    Thank you both!
    Now returning to the world of VB. Please make sure your seatbelts are securely fastened and all trays are in their upright and locked position.

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    vbNull <> vbNullString

    use VBNULLSTRING instead of VBNULL
    Remember, if someone's post was not helpful, you can always rate their post negatively .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width