472,342 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

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 1334
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Heros | last post by:
I had losed my serial key for .net Visual Studio Professional, DVD ROM with the trial version, 60 days, and need urgent to use it to install .net...
3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a...
9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY...
3
by: gani | last post by:
hi, how to get the fullpath of created IsolatedStorage directory. thanks. -- gani
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
1
by: samir dsf | last post by:
hi this is kinda urgent ... i will insert some data in html format..i just need to know how to disply it back.its urgent...so if anyone can...
2
by: tulasi | last post by:
Hi, Iam plcaing some textboxes and combo boxes in rictextbox control. And am placing 2 command buttons oin the form. So when i run the...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the...
4
by: Adrian Parker | last post by:
We've suddenly started getting a problem with a call to clear the contents of a DataTable. This is on a live customer site that's been working fine...
1
by: rajesh.us.it.recruiter | last post by:
Hi Guys/Partners, We have a URGENT Requirement for Perl Programmer with H1 visa in India/US for one of our prestigious Client. Location : New...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.