Re: convert string to byte array

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Patrick Cohan (patrickc_at_poly-tex.com.NO_SPAM)
Date: 02/05/04


Date: Thu, 5 Feb 2004 11:35:27 -0600

Compare:
> CaptureString = StrConv(code, vbFromUnicode)
VS.
CaptureString(index) = StrConv(code, vbFromUnicode)

That jumped out at me at first glimpse...see if that helps.

"Logan McKinley" <logan@globalweb.net> wrote in message
news:OCRap0A7DHA.452@TK2MSFTNGP11.phx.gbl...
> I have found two methods that should work but both return errors.
> First method:
> Const MaxCaptureData = 2000
> Dim CaptureString(MaxCaptureData) As Byte
> Dim code As String
> code = "&#x0;&#x0;&#x8;&#x0;?&#x0;" 'this is just part of what the real
> code would be
> CaptureString = StrConv(code, vbFromUnicode)
> '-------------------
> this returns Compile error: Can't assign to array
>
> Second method:
>
> Const MaxCaptureData = 2000
> Dim CaptureString(MaxCaptureData) As Byte
> Private Declare Sub CopyMemory Lib "kernel32" Alias _
> "RtlMoveMemory" ( _
> hpvDest As Any, _
> hpvSource As Any, _
> ByVal cbCopy As Long)
>
> Dim code As String
> code = "&#x0;&#x0;&#x8;&#x0;?&#x0;" 'this is just part of what the real
> code would be
> CopyMemory CaptureString, ByVal code, Len(code)
> '----------------------
> this returns Compile error: Type mismatch
>
> I assume i am doing something stupid in both cases,
> Thanks in advance,
> ~Logan
>
>
>
>