Results 1 to 7 of 7

Thread: Hex to decimal [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Hex to decimal [RESOLVED]

    Can anyone help me please?

    I am trying to convert a Hex value into an decimal, i am using a variable so i cannot use:

    VB Code:
    1. Cint(&HA&)

    is there a quick function to do this?
    Last edited by mik706; Jun 20th, 2003 at 08:38 AM.
    Mik706

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    I'm not really sure what you are trying to do.

    Hex and decimal are just 2 ways of displaying the contents of your variable. You can't convert the variable from hex to decimal.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147
    I have for example a string:
    VB Code:
    1. message

    this string contaings "8A"

    i want to convert this from a hex representation to a decimal ie

    Cint(&H8A&) = 138
    Mik706

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Hex to decimal

    What's the variable type?

    What's stored in the variable?


    If it is a string, containing "&HA" then Cint(variable) will work fine

    if it is just "A" then use Cint("&H" & variable)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147
    Thanks Si i think i have been trying to over complicate the problem.
    Mik706

  6. #6
    New Member
    Join Date
    Jan 2004
    Location
    philippines
    Posts
    2
    Help! Got the same problem but it wont work when i need to convert this hex value(CB00) It should convert to 51,968 decimal.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147
    Try:

    VB Code:
    1. Dim hHex As String
    2. Dim dDec As Long
    3.  
    4. hHex = "CB00"
    5.    
    6. dDec = CLng("&H" & hHex)
    7.  
    8. msgbox dDec
    Mik706

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