Important Please Help 
Author Message
 Important Please Help

Hi.. My friend and I are writing some client/server application with VB5 and
have a problem. We want to send, not a string, but an array of bytes. I say
not a string, because Win95 string format is Unicoded coded (2 bytes = 1
character, first byte being the ASCII character itself followed by a null)
and we just don' t want to send such an array.

All I want you to tell me, is how can we manipulate strings in binary format
(as we often do in C++, where strings can be -real- null terminated
strings). Is there a function or is it possible to make one that will easily
manipulate and extract bytes in/from a string ??..

Quad



Thu, 20 Sep 2001 04:00:00 GMT  
 Important Please Help
Hi Quad,

    It's hard to tell from your description exactly what you're trying to
do, but here are a few facts that might be helpful.

1) If you are sending a string to a C/C++ function via a Declare statement,
VB will automatically convert the Unicode string to an ANSI string (be sure
your string argument is declared ByVal in the Declare statement or evil
things will happen)

2) You can convert the contents of a string variable in VB between Unicode
and ANSI by using the StrConv function.

    Convert from Unicode to ANSI:
        szMyString = StrConv(szMyString, vbFromUnicode)

    Convert from ANSI to Unicode:
       szMyString = StrConv(szMyString, vbUnicode)

3) If you want to directly manipulate the bytes of either variety of string
you can simply assign your string to a dynamic Byte array, do your
manipulation, then assign the Byte array back to a string variable. VB
allows this type of assignment automatically:

    Sub Demo()

        Dim bytMyByte() As Byte
        Dim szMyString As String

        szMyString = "This is my string"
        bytMyByte = szMyString
            ''' Do something here.
        szMyString = bytMyByte

    End Sub

--
Rob Bovey, MCSE
The Payne Consulting Group
http://www.payneconsulting.com
* Post follow up questions to this newsgroup *
* I do not respond to questions sent via e-mail *

Quote:

>Hi.. My friend and I are writing some client/server application with VB5
and
>have a problem. We want to send, not a string, but an array of bytes. I say
>not a string, because Win95 string format is Unicoded coded (2 bytes = 1
>character, first byte being the ASCII character itself followed by a null)
>and we just don' t want to send such an array.

>All I want you to tell me, is how can we manipulate strings in binary
format
>(as we often do in C++, where strings can be -real- null terminated
>strings). Is there a function or is it possible to make one that will
easily
>manipulate and extract bytes in/from a string ??..

>Quad




Thu, 20 Sep 2001 04:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Important Please Help

2. Important Please Help

3. Important Please Help...

4. Loading PCX (important, please help!)

5. Important Please Help

6. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

7. important database question, please help me?

8. please help me !!!!!!!!!!!!!! it very important

9. Need Help please, very important...

10. Components/ASP problem . Please help,very important

11. Please help...This is important.

12. Please help...This is important.

 

 
Powered by phpBB® Forum Software