Results 1 to 6 of 6

Thread: remove null termination from string...

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    remove null termination from string...

    I am using an API call that you pass a string buffer to and it returns a value.. its fine except that I need to concat the return value with another string in my function and return this total value. but since this string that is returned by the API call is null terminated, the concat doesnt work... so I need to string this return value of the null terminator.. any idea?

    I tried trim, assigning it to another string, and several other things to get it to work..

    while writing this I got an idea and tried it and it works...
    Temp = Temp.Substring(0, Temp.Length - 1)

    where temp was the trim value of the return string from the API function

    but is this the most practicle way? or is there another common method for dealing with these types of strings?

  2. #2
    Addicted Member d.patrick's Avatar
    Join Date
    Nov 2004
    Location
    Oshkosh, WI
    Posts
    172

    Re: remove null termination from string...

    I have been in your exact situation and ended up doing just what you did. If there is a better way I sure would like to know what it is.

  3. #3
    New Member
    Join Date
    Feb 2016
    Posts
    1

    Re: remove null termination from string...

    try this
    sFileName = Left(sFileName, Len(sFileName) - 1)
    sFileName is a string.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: remove null termination from string...

    Matt, maybe this,

    Code:
    somestring.TrimEnd(ControlChars.NullChar)
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: remove null termination from string...

    Well, if after 12 years Kleinma hadn't found the answer... there is no hope for the rest of us.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: remove null termination from string...

    Quote Originally Posted by techgnome View Post
    Well, if after 12 years Kleinma hadn't found the answer... there is no hope for the rest of us.

    -tg
    Can I get an Amen...
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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