Re: VBScript OCX receive and supply a safeArray of type VT_UI1- problem
Newyana2 <[email protected]>
| Newsgroups | alt.comp.os.windows-xp,alt.windows7.general,comp.os.ms-windows.programmer.win32 |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 5/21/2024 2:44 PM, R.Wieser wrote:
> I've just build an OCX for usage within vbscript, and am running into a
> problem :
>
> I'm trying to have a method #1 return a SafeArray of type VT_UI1, and later
> provide it to a method #2.
>
What JJ said. VBS doesn't do datatypes. You have
two choices: Convert each array element to variant
when assigning it, or don't use an array. I typically
use a character-delimited string that can be converted
to array easily by the caller:
Dim c1
c1 = Chr(1)
s = "one" & c1 & "2" & c1 & "three"
a = Split(s, c1)
For i = 0 to 2
MsgBox a(i)
next
The caller can convert the string to a variant array in one
simple line. You don't have to convert the string to variant
until the final act of your function: Get3Numbers = CVar(s)
If you want to return an array then you have to convert each
array member individually.