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

I

ItsMe

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
 
T

Tom Shelton

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

ItsMe

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\WindowsApplication1\WindowsApplication1\F
orm1.vb:line 142"

Please help........
Regards
 
I

ItsMe

ItsMe said:
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\WindowsApplication1\WindowsApplication1\F
orm1.vb:line 142"

Please help........
Regards


to
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top