Click to See Complete Forum and Search --> : variable problems


DiFabs
April 6th, 2001, 10:51 AM
I have a Variable Problem, that is being fill but I can't read it
I'm sending the variable to a DLL which is declared;
Private Declare Function GetList Lib "C:\Program Files\Microsoft Visual Studio\MyProjects\API\Debug\API.dll" _
(ByVal pszSch As String, ByVal pszQualifier As String, vNumber As Variant, ByVal pszMessage As String) As Long

The Function that calls this DLL is;
Private Sub Command1_Click()
Dim xStatus As Integer
Dim pszSch As String
Dim pszMessage As String
Dim pszQualifier As String
Dim vNumber As Variant
ReDim vNumber(2002) As String

pszS = "TEST"
pszQualifier = " 'COM_NUM' = 123"
pszMessage = Space$(255)

xStatus = GetList(pszSch, pszQualifier, vNumber, pszMessage)
MsgBox vNumber(x), vbInformation, "vNumber"
Text1 = vNumber(x)


The MsgBox line with the vNumber will display the value in the variable
But the Text1 line shows nothing for the variable
What do I do to read this variable without the message box ?

thanks

shree
April 6th, 2001, 11:03 AM
Why do you simply not do

Dim vNumber(2002) as String

or

Dim vNumber() as String

Redim vNumber(2002)

DiFabs
April 6th, 2001, 12:17 PM
You must declared the variable as a variant because the C++ DLL wants a variant variable, I then need to specify that it is a string type by ReDim
Dim vTicketNumber As Variant
ReDim vTicketNumber(2002) As String
I have tried other ways of declaring and passing the variable into C++ DLL
but this is the only way to pass the variable (array) to DLL

and it works fine...when its in a message box, but for everything else its empty
if you can suggest another way to go about this, other then that, I can't understand why the variable is empty

Clearcode
April 6th, 2001, 12:22 PM
Text1.Text = CStr(vNumber(x))




HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

DiFabs
April 6th, 2001, 12:37 PM
That won't do it
that just converts the variable from a number to a string
the variable is already a string

I believe it has something to do with the memory location, the Message box somehow must be pulling the variable differently