By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,190 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,190 IT Pros & Developers. It's quick & easy.

String Array Issue - VB 2005

P: n/a
Hi Friends,

Any help would be highly appreciated for the following problem :

I have a vb 6 application which makes call to an API in some dll
which returns an array of strings and no of elements in that array :

Declare Function vb_inq_applications Lib "tcvbodss.dll" (ByVal
login_handle As Integer, ByRef no_of_elements As Integer, ByRef
str_array() As String, ByRef handle As Integer) As

Integer

Dim handle As Integer
Dim no_of_elements As Integer
Dim str_array(16) As String

retcode = check_apps(login_handle, no_of_elements,
str_array(), handle)

For i = 1 To UBound(str_array)
Debug.Print str_array(i)
Next i

This code worked absolutely fine untill I upgraded this to VB 2005 .
Now str_array() is not filled with data but the no_of_elements comes
correctly , following is the upgraded code :

Declare Function vb_inq_applications Lib "tcvbodss.dll" (ByVal
login_handle As Short, ByRef no_of_elements As Short, ByRef
str_array() As String, ByRef handle As Short) As Short

Dim handle As Integer
Dim no_of_elements As Integer
Dim str_array(16) As String
ReDim str_array(16)

retcode = check_apps(login_handle, no_of_elements, str_array,
handle)

For i = 1 To UBound(str_array)
Console.WriteLine str_array(i)
Next i

I am unable to locate the PROBLEM , kindly help me to short out this
issue.

Aug 9 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Phoenix,

Try the following :

Declare Function vb_inq_applications Lib "tcvbodss.dll" ( _
ByVal login_handle As Int16, _
ByRef no_of_elements As Int16, _
<InAttribute(), OutAttribute(), MarshalAs(UnmanagedType.SafeArray)ByRef
str_array() As String, _
ByRef handle As Int16) As Int16

Dim handle As Int16
Dim no_of_elements As Int16
Dim str_array(16) As String

retcode = check_apps(login_handle, no_of_elements, str_array,
handle)

For i = 0 To UBound(str_array)
Console.WriteLine str_array(i)
Next i
If that doesn't work try changing the str_array to ByVal instead of ByRef in
the vb_inq_applications declaration.

Regards,

Bill


"Phoenix" <su************@gmail.comwrote in message
news:11**********************@g12g2000prg.googlegr oups.com...
Hi Friends,

Any help would be highly appreciated for the following problem :

I have a vb 6 application which makes call to an API in some dll
which returns an array of strings and no of elements in that array :

Declare Function vb_inq_applications Lib "tcvbodss.dll" (ByVal
login_handle As Integer, ByRef no_of_elements As Integer, ByRef
str_array() As String, ByRef handle As Integer) As

Integer

Dim handle As Integer
Dim no_of_elements As Integer
Dim str_array(16) As String

retcode = check_apps(login_handle, no_of_elements,
str_array(), handle)

For i = 1 To UBound(str_array)
Debug.Print str_array(i)
Next i

This code worked absolutely fine untill I upgraded this to VB 2005 .
Now str_array() is not filled with data but the no_of_elements comes
correctly , following is the upgraded code :

Declare Function vb_inq_applications Lib "tcvbodss.dll" (ByVal
login_handle As Short, ByRef no_of_elements As Short, ByRef
str_array() As String, ByRef handle As Short) As Short

Dim handle As Integer
Dim no_of_elements As Integer
Dim str_array(16) As String
ReDim str_array(16)

retcode = check_apps(login_handle, no_of_elements, str_array,
handle)

For i = 1 To UBound(str_array)
Console.WriteLine str_array(i)
Next i

I am unable to locate the PROBLEM , kindly help me to short out this
issue.
Aug 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.