如何在VB6中将十六进制值转换为十进制值?
我正试图看看它是否有效:
Dim hexVal as string
hexVal = "#7B19AB"
clng("&H" & hexVal)
但是,我收到“输入错误匹配”错误。
答案 0 :(得分:10)
摆脱#符号
Dim hexVal as string
hexVal = "7B19AB"
clng("&H" & hexVal)
答案 1 :(得分:4)
删除hexVal字符串中的数字符号(#)。
答案 2 :(得分:1)
这应该这样做
Dim hexVal as String
hexVal = "#7B19AB"
Dim intVal as Integer
intVal = Val("&H" & Replace(hexVal, "#", ""))
答案 3 :(得分:1)
试一试:
value=CDbl("&H" & HexValue)
或
value=CInt("&H" & HexValue) 'but range +- 32,768
答案 4 :(得分:1)
以这种方式尝试:
Print Hex(Asc(Text1.Text))
答案 5 :(得分:0)
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
答案 6 :(得分:0)
Dim hexVal As String
Dim str As String
Dim uzunluk As Integer
On Error Resume Next
hexVal = "#7B19AB"
str = Replace(hexVal, "#", "")
Text1.Text = str
uzunluk = Len(Text1.Text)
For i = 0 To uzunluk
Text1.SelStart = i
Text1.SelLength = 1
Print Hex(Asc(Text1.SelText))
Next i
答案 7 :(得分:0)
要非常小心。
Dim hexVal as string
hexVal = "FFFF"
clng("&H" & hexVal)
将返回值-1,因为它认为您的HEX值已签名。 看看F00A发生了什么,再次认为它已签名。
用ABS替换Clng。