View Full Version : passing a string from oxygen to vb6

24-07-2009, 21:36
Hi Charles, Hi all
i have found this case while trying to pass a string from the Oxygen dll to vb6 :
1-we must declare in vb6 a fixed string of certain lenght, and not a dynamic string.
2- when using v = o2_exec , we use the api function lstrcpy to copy the string from the address pointed to by v to the vb6 fixed string.
there are two methods to declare a fixed string in vb6, either by using space(number) after dimming the variable as a string, or by dim ss as string * Number

i have found this method from looking in a lesson in calling a purebasic dll from vb6.
this way we can copy whatever the contents of the O2 msgbox to a fixed lenght string in vb6.

the vb6 project here:

Private Declare Function lstrcpy Lib "Kernel32.dll" (ByVal MyString As String, ByVal MyLong As Long) As Long
Private Sub Command1_Click()
Dim src As String
Dim stringOne As String
stringOne = Space(2000)
Dim stringTwo As String * 2000
Dim v As Long
Dim ss As String
ss = "This is a string"

src = " dim a as string :"
src = src & "a = " & "`" & ss & "`" & ": Print a: terminate "
o2_basic src
v = o2_exec
Res = lstrcpy(stringOne, v)
MsgBox stringOne, , "I am from vb6"

o2_basic src
v = o2_exec
Res = lstrcpy(stringTwo, v)
MsgBox stringTwo, , "I am from vb6"
End Sub