is there an VB.Net alias for the vb6 - Val()- function
(convertering string to integer)
thx in advance
Printable View
is there an VB.Net alias for the vb6 - Val()- function
(convertering string to integer)
thx in advance
Hi,
It is the same.
Look at the static Convert function .
Integer.Parse() is another way.
Hi again ,
I can't use the others functions?...
this is what i want todo ...
this calls following function in another class :Code:Private Sub btnInp32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInp32.Click
txtInp32.Text = Convert.ToString(InP(Val("&H0378")))
End Sub
and this is the error i getting :Code:Declare Auto Function InP Lib "inpout32.dll" Alias "Inp32" (ByVal portAddress As Integer) As Integer
he takes the string only with the old Val() function ?Code:An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
And because i want to be part of the DOT NET hype :D
i'm looking for the .Net function .....
THX for your time and effort
Hi,
I'm afraid that as far as I am concerned you are creating a thick fog!!
The error message you get indicates that the parameter passed to mscorlib.dll is at fault. You don't show us your calling routine nor the code of mscorlib.dll.
Along the way in
txtInp32.Text = Convert.ToString(InP(Val("&H0378")))
You take a string; convert it to a number; then convert it back to a string using a function "InP" of which I am totally ignorant.
What does that API do ? There's maybe function that does equivalent job in .NET .
The API is to talk with the parallel port directly.
The Function ("Inp") is located in the library "inpout32.dll", and i have wrapped it in a class named "InpOut".
This is the API :
Now i want to call the function from a form and pass a parameter "Port address" (integer)Code:Declare Auto Function InP Lib "inpout32.dll" Alias "Inp32" (ByVal portAddress As Integer) As Integer
This works !!! but i want to use another function instead of Val()!Code:InP(Val("&H0378"))
Val() converts a string to an integer, but its from the Old Visual basic :D
I want to use a new function like: Inp(Convert.toInt16("&H0378"))
and this doesnt work !
Hi
"InP(Val("&H0378"))"
Have you tried
InP(&H0378)
I suggest this because the "&" denotes a hex number following.
Thanks !
Yours works and i have found it with the parse function !
I cant use the "&H" sign
Code:integer.Parse("0378", Globalization.NumberStyles.AllowHexSpecifier)