Convert hex value to a decimal value in VB6

前端 未结 8 2169
日久生厌
日久生厌 2021-02-20 04:08

How can I convert a hex value to a decimal value in VB6?

I\'m trying just to see if this works:

Dim hexVal as string
hexVal = \"#7B19AB\"
clng(\"&H\         


        
相关标签:
8条回答
  • 2021-02-20 04:17

    Try it this way:

    Print Hex(Asc(Text1.Text))
    
    0 讨论(0)
  • 2021-02-20 04:18

    Be very carful.

    Dim hexVal as string
    hexVal = "FFFF"
    clng("&H" & hexVal)
    

    will return a value of -1 because it thinks your HEX value is signed. See what happens with F00A, again it thinks its signed.

    Replace the Clng with ABS.

    0 讨论(0)
  • 2021-02-20 04:21

    Get rid of the # sign

    Dim hexVal as string
    hexVal = "7B19AB"
    clng("&H" & hexVal)
    
    0 讨论(0)
  • 2021-02-20 04:22
    Dim uzunluk as Integer
    
    On Error Resume Next
    uzunluk = Len(Text1.Text)
    For i = 0 To uzunluk
         Text1.SelStart = i
         Text1.SelLength = 1
         Print Hex(Asc(Text1.SelText))
    Next i
    
    0 讨论(0)
  • 2021-02-20 04:24

    This should do it

    Dim hexVal as String
    hexVal = "#7B19AB"
    Dim intVal as Integer
    intVal = Val("&H" & Replace(hexVal, "#", ""))
    
    0 讨论(0)
  • 2021-02-20 04:26

    Try It:

    value=CDbl("&H" & HexValue) 
    

    or

    value=CInt("&H" & HexValue) 'but range +- 32,768
    
    0 讨论(0)
提交回复
热议问题