Re: convert VC++ code into VB6




"David Anton" <DavidAnton@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9ED5EFF5-F7C7-457F-9090-9569AFE7937D@xxxxxxxxxxxxxxxx
The following conversion was produced by 'C++ to VB Converter', but the
output is VB.NET, so you will have to change Console.Write to something
else
for VB6 I believe:

Dim pSno As Integer
Dim count As Integer = CKT_ReportConnections(pSno)
For i As Integer = 0 To count - 1
Console.Write("{0:D}", pSno(i))
Next i

You can't convert a pointer to an Integer and then subscript it, so that's
wrong even in VB.NET. Data types are also different from VB.NET to VB6.

Something like this would work in VB6:

Dim pSno As Long
Dim count As Integer = CKT_ReportConnections(pSno)
Dim Sno(0 To count - 1) As Long
MoveMemory(ByRef Sno(0), pSno, 4 * count)

now the data is in a VB6 array named Sno

Get the import declaration for function MoveMemory from winapi.txt


--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter


"jiuge.quan@xxxxxxxxx" wrote:

we have a function in a dll. Its protocol is:
int __stdcall CKT_ReportConnections(int **pSno);

VC demo code is:
[
int *pSno;
int count = CKT_ReportConnections(&pSno);
for (int i=0; i<count; ++i)
printf("%d", pSno[i]);
]


How can I write the same in VB6?


I may know this function declaration that maybe is :


[
Public Declare Function CKT_ReportConnections Lib
"DLLNAME.dll" (ByRef
pSno As Long) As Long
]


But then what i should write the above demo in VB6?


Thx a lot.




.



Relevant Pages

  • Re: how convert vc++ code into vb?
    ... I may know this function declaration that maybe is: ... pSno As Long) As Long ... But then what i should write the above demo in VB6? ... Dim aSno() As Long ...
    (microsoft.public.vb.general.discussion)
  • RE: convert VC++ code into VB6
    ... The following conversion was produced by 'C++ to VB Converter', ... Dim pSno As Integer ... How can I write the same in VB6? ... Public Declare Function CKT_ReportConnections Lib ...
    (microsoft.public.vc.language)
  • RE: Converting VB6 Fileopen/input/close to vb.net
    ... swallow and spit it out as a single string. ... stand alone components set for those VB6 file methods(such as FileOpen, ... Dim file_num As Integer = FreeFile ... For standard binary file read/write, in .NET, you can use BinaryReader ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Back to VB6 and .NET
    ... memory than it is with prior libraries. ... Dim tExceptions As New DataTable ... It works slightly better than VB6 Edit and Continue. ... a DLL which is loaded by Orbiter to run the add-on (like a Project ...
    (microsoft.public.vb.general.discussion)
  • Re: VB.NET 2008 not backward compatable?
    ... Dim sb As New StringBuilder ... The explanation I see for it implies that VB6 ... I couldn't have a second bar, band, or other shell extension ... can you load two different vb runtimes into the same process? ...
    (microsoft.public.dotnet.languages.vb)

Loading