Results 1 to 6 of 6

Thread: Who knows this ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Posts
    29
    I'm trying to convert a hex value to a decimal value
    I'm really stuck here.

    My programs has to go into the header of a dbf file and reverse 4 digists

    ex.

    00 00 06 99
    99 06 00 00

    New values is 996 is the new hex value

    Now I need to convert it to decimal value.

    Any clues?

    I used the computer calculator and it works fine so there has to be a way.


    Bruno

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    HexString->LongValue


    Code:
      Dim strHex As String
      Dim lngVal as Long
    
    
      strHex = "D00D"
    
      lngVal = CLng("&H" & strHex)
    there ya go, easy enough?
    -Shickadance

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    beat me 2 it
    or i = CInt("&h" & s)

  4. #4
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    Try This:

    Code:
    MYHEX$ = "7FFFFFFF"
    Mydec& = Val("&H" & MYHEX$)
    NOTE: This was a example I saw on Planet Source Code!

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    FYI... Val() is ok to use but, remember it returns a Double. So it has to cast to a byte/integer/long etc. which results in a small performance hit.
    -Shickadance

  6. #6
    Guest
    Also, keep in mind that Val() is usually used to convert strings to numbers. When you want to convert numbers, use CDbl().

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