473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

String Array Issue - VB 2005

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
1 4258
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Richard | last post by:
Here is the program problem: Month with 30 days have 720 hours, and month with 31 days have 744 hours. February, with 28 days, has 672 hours. Enhance the input validation of the program code...
23
by: Nascimento | last post by:
Hello, How to I do to return a string as a result of a function. I wrote the following function: char prt_tralha(int num) { int i; char tralha;
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
17
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
18
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
1
by: Joe Cool | last post by:
Using VB.NET 2005. I will not go into detail on a problem I can't figure out, but I will describe it simple terms that should convey the underlying issue. I have a class called ClassA. It has...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
14
by: Shhnwz.a | last post by:
Hi, I am in confusion regarding jargons. When it is technically correct to say.. String or Character Array.in c. just give me your perspectives in this issue. Thanx in Advance.
0
by: Phoenix | last post by:
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.