convert VC++ code into VB6  
Author Message
dias





PostPosted: Thu Sep 27 07:38:01 PDT 2007 Top

Visual Studio C++ >> convert VC++ code into VB6 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.

Visual Studio198  
 
 
DavidAnton





PostPosted: Thu Sep 27 07:38:01 PDT 2007 Top

Visual Studio C++ >> convert VC++ code into VB6 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

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


"EMail@HideDomain.com" 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.
>
>
 
 
Ben





PostPosted: Thu Sep 27 10:44:54 PDT 2007 Top

Visual Studio C++ >> convert VC++ code into VB6
"David Anton" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> 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
>
>
> "EMail@HideDomain.com" 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.
>>
>>