473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4269
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.