469,331 Members | 4,169 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

URGENT-help regd. code coversion sample from classic vb to vb.net

Hi Guyz,

I'm developing some application using third party api. They have given me
sample project which is in VB6.0. I'm a newbie in vb.net. and the classic vb
works perfectly alright. My job is to convert this vb6.0 application to .NET

At the beginning itself i got stuck. I've no idea how to declare these kind
of variables.

a) Public Declare Function fsmGetStatus& Lib "FSMFUJI.dll" (ByVal
strDocStatus$)
b) Public Declare Function fsmProcessDoc& Lib "FSMFUJI.dll" (ByVal
lngPocket&, ByVal lngDoubleFeed&, ByVal strEncodeData$, ByVal
strPrintData1$, ByVal strPrintData2$, ByVal strPrintData3$, ByVal
lngStampOn&, ByVal strMICR$, ByVal strOCR$, ByRef lngPocketRet&, ByRef
lngUnitNum&, ByRef lngMICRStatus&, ByVal strDocStatus$)

When I try to convert the code, it gives me lot of error. Just give me a
clue about this. I'm stuck guyz, deadline is on my head. Your help will be
highly appreciated.

Cheerz
Nov 20 '05 #1
3 1233
On 2004-04-15, ItsMe <kk*@yahoo.com> wrote:
Hi Guyz,

I'm developing some application using third party api. They have given me
sample project which is in VB6.0. I'm a newbie in vb.net. and the classic vb
works perfectly alright. My job is to convert this vb6.0 application to .NET

At the beginning itself i got stuck. I've no idea how to declare these kind
of variables.

a) Public Declare Function fsmGetStatus& Lib "FSMFUJI.dll" (ByVal
strDocStatus$)


Public Declare Sub fsmGetStatus Lib "fsmfuji.dll"
(ByVal strDocStatus As System.Text.StringBuilder)
That's assuming your trying to get output from the function and that it
really doesn't return a value.

You'll want to look up the type declaration characters in VB6:

$ = string
& = long

etc. Then, you'll want to convert those types to there VB.NET
equivalents. Such as Long in VB6 should be as Integer in VB.NET, since
a .NET integer is 32-bit. Using strings in declares is a bad idea if
you are recieving data (the api call is altering the string). It's ok
for constant buffers (you're passing info in, but the api call is not
altering the data), but causes a lot of extra overhead when it needs to
be altered by the external call. In those cases then you'll want to
make sure you declare the function as System.Text.StringBuilder. Then
you can use it like this:

Dim buffer As New StringBuilder(256)
fsmGetStatus(buffer)
Console.WriteLine(buffer.ToString())

Anyway, hope that's enough to get you started :) If you need more
information, try looking for references to P/Invoke in the docs.

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
FORTH IF HONK THEN
Nov 20 '05 #2
Hi Tom,

Thanks a lot for the reply. I've changed my code as per your advise. Its ok
now. Please have a look

Declaration:
========
Public Declare Function fsmHVStartScan Lib "D:\DLLs\FSMFUJI.dll" _
(ByVal lngNumDocs As Int16, ByVal strMICR As System.Text.StringBuilder, _
ByVal strOCR As System.Text.StringBuilder, ByRef lngPocket As Int16, _
ByRef lngUnitNum As Int16, ByRef lngMICRStatus As Int16, _
ByVal lngDoubleFeed As Int16, _
ByVal strDocStatus As System.Text.StringBuilder) As Int16
I've a slight problem here, and i'm unable to fix it.

Implementation:
==========
MsgBox(fsmHVStartScan(lngBatchSize, vbNullString, vbNullString, iPocket,
lngUnitNum, lngMICRStatus, lngDoubleFeed, vbNullString))

Error Message:
==========
"System.NullReferenceException: Object reference not set to an instance of
an object.
at WindowsApplication1.Module1.fsmHVStartScan(Int16 lngNumDocs,
StringBuilder strMICR, StringBuilder strOCR, Int16& lngPocket, Int16&
lngUnitNum, Int16& lngMICRStatus, Int16 lngDoubleFeed, StringBuilder
strDocStatus)
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in
C:\Documents and
Settings\Administrator\Desktop\xxx\WindowsApplicat ion1\WindowsApplication1\F
orm1.vb:line 142"

Please help........
Regards
"Tom Shelton" <to*@mtogden.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
On 2004-04-15, ItsMe <kk*@yahoo.com> wrote:
Hi Guyz,

I'm developing some application using third party api. They have given me sample project which is in VB6.0. I'm a newbie in vb.net. and the classic vb works perfectly alright. My job is to convert this vb6.0 application to ..NET
At the beginning itself i got stuck. I've no idea how to declare these kind of variables.

a) Public Declare Function fsmGetStatus& Lib "FSMFUJI.dll" (ByVal
strDocStatus$)


Public Declare Sub fsmGetStatus Lib "fsmfuji.dll"
(ByVal strDocStatus As System.Text.StringBuilder)
That's assuming your trying to get output from the function and that it
really doesn't return a value.

You'll want to look up the type declaration characters in VB6:

$ = string
& = long

etc. Then, you'll want to convert those types to there VB.NET
equivalents. Such as Long in VB6 should be as Integer in VB.NET, since
a .NET integer is 32-bit. Using strings in declares is a bad idea if
you are recieving data (the api call is altering the string). It's ok
for constant buffers (you're passing info in, but the api call is not
altering the data), but causes a lot of extra overhead when it needs to
be altered by the external call. In those cases then you'll want to
make sure you declare the function as System.Text.StringBuilder. Then
you can use it like this:

Dim buffer As New StringBuilder(256)
fsmGetStatus(buffer)
Console.WriteLine(buffer.ToString())

Anyway, hope that's enough to get you started :) If you need more
information, try looking for references to P/Invoke in the docs.

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
FORTH IF HONK THEN

Nov 20 '05 #3

"ItsMe" <kk*@yahoo.com> wrote in message
news:uc**************@tk2msftngp13.phx.gbl...
Hi Tom,

Thanks a lot for the reply. I've changed my code as per your advise. Its ok now. Please have a look

Declaration:
========
Public Declare Function fsmHVStartScan Lib "D:\DLLs\FSMFUJI.dll" _
(ByVal lngNumDocs As Int16, ByVal strMICR As System.Text.StringBuilder, _
ByVal strOCR As System.Text.StringBuilder, ByRef lngPocket As Int16, _
ByRef lngUnitNum As Int16, ByRef lngMICRStatus As Int16, _
ByVal lngDoubleFeed As Int16, _
ByVal strDocStatus As System.Text.StringBuilder) As Int16
I've a slight problem here, and i'm unable to fix it.

Implementation:
==========
MsgBox(fsmHVStartScan(lngBatchSize, vbNullString, vbNullString, iPocket,
lngUnitNum, lngMICRStatus, lngDoubleFeed, vbNullString))

Error Message:
==========
"System.NullReferenceException: Object reference not set to an instance of
an object.
at WindowsApplication1.Module1.fsmHVStartScan(Int16 lngNumDocs,
StringBuilder strMICR, StringBuilder strOCR, Int16& lngPocket, Int16&
lngUnitNum, Int16& lngMICRStatus, Int16 lngDoubleFeed, StringBuilder
strDocStatus)
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and
Settings\Administrator\Desktop\xxx\WindowsApplicat ion1\WindowsApplication1\F orm1.vb:line 142"

Please help........
Regards
"Tom Shelton" <to*@mtogden.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
On 2004-04-15, ItsMe <kk*@yahoo.com> wrote:
Hi Guyz,

I'm developing some application using third party api. They have given me sample project which is in VB6.0. I'm a newbie in vb.net. and the classic vb works perfectly alright. My job is to convert this vb6.0 application
to
.NET
At the beginning itself i got stuck. I've no idea how to declare these kind of variables.

a) Public Declare Function fsmGetStatus& Lib "FSMFUJI.dll" (ByVal
strDocStatus$)


Public Declare Sub fsmGetStatus Lib "fsmfuji.dll"
(ByVal strDocStatus As System.Text.StringBuilder)
That's assuming your trying to get output from the function and that it
really doesn't return a value.

You'll want to look up the type declaration characters in VB6:

$ = string
& = long

etc. Then, you'll want to convert those types to there VB.NET
equivalents. Such as Long in VB6 should be as Integer in VB.NET, since
a .NET integer is 32-bit. Using strings in declares is a bad idea if
you are recieving data (the api call is altering the string). It's ok
for constant buffers (you're passing info in, but the api call is not
altering the data), but causes a lot of extra overhead when it needs to
be altered by the external call. In those cases then you'll want to
make sure you declare the function as System.Text.StringBuilder. Then
you can use it like this:

Dim buffer As New StringBuilder(256)
fsmGetStatus(buffer)
Console.WriteLine(buffer.ToString())

Anyway, hope that's enough to get you started :) If you need more
information, try looking for references to P/Invoke in the docs.

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
FORTH IF HONK THEN


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Stefan Bauer | last post: by
3 posts views Thread by gani | last post: by
28 posts views Thread by Tamir Khason | last post: by
1 post views Thread by samir dsf | last post: by
2 posts views Thread by tulasi | last post: by
3 posts views Thread by N. Spiker | last post: by
4 posts views Thread by Adrian Parker | last post: by
1 post views Thread by rajesh.us.it.recruiter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.