Convert variant to array of byte 
Author Message
 Convert variant to array of byte

I have following problem:
In my application in VB I receive out parameter from Activex DLL written in
ATL.
ATL dll return variant, which store in BSTR binary information.

I must convert received variant to array of bytes (in VB).And store this
binar information on disk.

How I convert received variant with BSTR to array of bytes in VB?

Thanks.



Sat, 24 May 2003 03:00:00 GMT  
 Convert variant to array of byte
What is actually encoded in your BSTR, you did not specified.  Do
you want to write each byte of the BSTR, or each character as a
single byte?

You may need to use StrConv. Check docs on vbWide, vbNarrow, vbUnicode,
vbFromUnicode.  Can you NOT write the converted string to the file?

(search VB docs for DBCS to find following information)

If you want to handle strings of binary data, you can map the characters
in a string to a Byte array by using the following code:

Dim MyByteString() As Byte
' Map the string to a Byte array.
MyByteString = "ABC"
' Display the binary data.
For i = LBound(MyByteString) to UBound(MyByteString)
   Print Right(" " + Hex(MyByteString(i)),2) + " ,";
Next
Print

--
______________________________________________________________________
Lee Gillie, CCP                                Remove NOSPAM to E-Mail
Online Data Processing, Inc. - 3501 N. Haven -  Spokane, WA 99207-8500

Quote:
> I have following problem:
> In my application in VB I receive out parameter from Activex DLL written
in
> ATL.
> ATL dll return variant, which store in BSTR binary information.

> I must convert received variant to array of bytes (in VB).And store this
> binar information on disk.

> How I convert received variant with BSTR to array of bytes in VB?

> Thanks.



Sat, 24 May 2003 03:00:00 GMT  
 Convert variant to array of byte

Quote:
> I have following problem:

Prevet!

Dim myBytes() As Byte
Dim vtBSTR As Variant
Dim vtUI1 As Variant
vtBSTR = "hello world"
myBytes() = vtBSTR
vtUI1 = myBytes()

It can be done using 'plain basic' :)

Mnoho yspexa!
--

Nierop Webconsultancy
Check the new ASP Session replacer for webfarms at
http://www.nieropwebconsult.nl/asp_session_manager.htm

+31 6 50 287 251
The Netherlands, Amsterdam



Sun, 25 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Convert variant to array of byte

2. Convert variant to array of byte

3. Convert user defined type or variant to byte array (and back)

4. Converting a Variant To an array of bytes!

5. Convert byte array to variant

6. Need to convert a 16 byte array of bytes to 4 byte integer

7. Converting string array to byte array

8. Array to Variant and Variant to array problem

9. Passing variant containing byte array

10. Variant (array of bytes)

11. Move data from a variant to byte array

12. Variant (array of bytes)

 

 
Powered by phpBB® Forum Software