DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Posts
    2

    Exclamation 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.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    Welcome to DevX.

    Are you getting errors or just no data?

    Do you have Option Strict On?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Aug 2007
    Posts
    2

    Small Breakthrough & BIG Surprise :

    When I change string declarartion as below :

    <MarshalAs(UnmanagedType.SafeArray, SafeArraySubType:=VarEnum.VT_BSTR)> ByRef os_apl_ids() As String

    I am getting the data but its not printing correctly except the LAST CHARACTER :

    Output is follows :

    Application : 0 ?????
    Application : 1 ????2
    Application : 2 ???l
    Application : 3 ???d
    Application : 4 ???n

    STRANGE thing is last character is correct except in the first case but not the CHARACTER count.

    Any help will be gr8 . . . I am completely LOST

Similar Threads

  1. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 11:18 AM
  2. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 03:53 AM
  3. Replies: 1
    Last Post: 06-05-2001, 06:12 AM
  4. SafeArrayCopy SLOWER than iterating string array!
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 0
    Last Post: 06-12-2000, 08:15 PM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 03:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links