Results 1 to 10 of 10

Thread: alias for Val() function ? [RESOLVED]

  1. #1

    Thread Starter
    New Member Object's Avatar
    Join Date
    Jan 2004
    Location
    Belgium
    Posts
    11

    Lightbulb alias for Val() function ? [RESOLVED]

    is there an VB.Net alias for the vb6 - Val()- function

    (convertering string to integer)


    thx in advance
    Last edited by Object; Apr 4th, 2004 at 09:32 AM.
    2 things are infinite! the Universe and human stupidity =-)

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    It is the same.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Look at the static Convert function .

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Integer.Parse() is another way.

  5. #5

    Thread Starter
    New Member Object's Avatar
    Join Date
    Jan 2004
    Location
    Belgium
    Posts
    11
    Hi again ,
    I can't use the others functions?...
    this is what i want todo ...

    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
    this calls following function in another class :


    Code:
    Declare Auto Function InP Lib "inpout32.dll" Alias "Inp32"  (ByVal portAddress As Integer) As Integer
    and this is the error i getting :

    Code:
    An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
    
    Additional information: Input string was not in a correct format.
    he takes the string only with the old Val() function ?
    And because i want to be part of the DOT NET hype
    i'm looking for the .Net function .....

    THX for your time and effort
    2 things are infinite! the Universe and human stupidity =-)

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What does that API do ? There's maybe function that does equivalent job in .NET .

  8. #8

    Thread Starter
    New Member Object's Avatar
    Join Date
    Jan 2004
    Location
    Belgium
    Posts
    11
    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 :
    Code:
    Declare Auto Function InP Lib "inpout32.dll" Alias "Inp32" (ByVal portAddress As Integer) As Integer
    Now i want to call the function from a form and pass a parameter "Port address" (integer)
    Code:
    InP(Val("&H0378"))
    This works !!! but i want to use another function instead of Val()!

    Val() converts a string to an integer, but its from the Old Visual basic
    I want to use a new function like: Inp(Convert.toInt16("&H0378"))
    and this doesnt work !
    2 things are infinite! the Universe and human stupidity =-)

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi

    "InP(Val("&H0378"))"

    Have you tried

    InP(&H0378)

    I suggest this because the "&" denotes a hex number following.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  10. #10

    Thread Starter
    New Member Object's Avatar
    Join Date
    Jan 2004
    Location
    Belgium
    Posts
    11

    Talking RESOLVED

    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)
    2 things are infinite! the Universe and human stupidity =-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width