Results 1 to 4 of 4

Thread: Working with Buffer(n) As Bytes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Garden Grove, CA, USA
    Posts
    110
    hello,
    i've tried to use winsock over API codes and got it working, and when ever data is receive i will catch in Buffer(1000) as Bytes. the problem is that even though the data received did not fill up 1000 bytes the length of the encoded text is still 1000 bytes. How can i reduce it back to it's actual size? for example: "PING :irc.webmaster.com" to it's actual length as 23 characters?
    ngphuocthinh

  2. #2
    Guest
    Try storing the length in an integer if you want to keep it in that way.

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    ehhrrmm... You have it in a byte array and want to change the dimensions?

    Code:
    'like
    Dim b() as Byte  '?
    then try (I haven't tried it yet)
    
    Redim Preserve b(uBound(b))
    Have fun!

    Edit...

    Ah sh*t!
    I just realized it was really dumb i was trying to do
    'cause Ubound gives the upper bound of the array, not the upper bound of the filled contents... hmm.. sorry mate!


    [Edited by Jop on 11-21-2000 at 09:34 AM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    If the api returns ANSI text you could use this:

    sText = StrConv(Buffer, vbUnicode)
    sText = Left(sText, InStr(sText, Chr(0)) - 1)

    And if the api returns Unicode you could do it like this:

    sText = Buffer
    sText = Left(sText, InStr(sText, Chr(0)) - 1)

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