CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2000
    Posts
    23

    variable problems

    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



  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: variable problems

    Why do you simply not do

    Dim vNumber(2002) as String

    or

    Dim vNumber() as String

    Redim vNumber(2002)


  3. #3
    Join Date
    Sep 2000
    Posts
    23

    Re: variable problems

    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


  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: variable problems


    Text1.Text = CStr(vNumber(x))




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Sep 2000
    Posts
    23

    Re: variable problems

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured