Private Sub Command1_Click()
Dim x As String, ch As String
Dim flag As Boolean, i As Integer, result As Long
x = ①
i = 1
result = 0
flag = True
ch = Mid(x, 1, 1)
Do While i <= Len(x) And flag = True
If ch >= "0" And ch <= "9" Then
result = result * 16 + Val(ch)
ElseIf ch >= "A" And ch <= "F" Then
result = result * 16 + (Asc(ch) - Asc("A") + 10)
ElseIf ch >= "a" And ch <= "f" Then
result = result * 16 + (Asc(ch) - Asc("a") + 10)
Else
flag = False
End If
i = i + 1
ch = ②
Loop
If flag = True Then
Label3.Caption = Str(result)
Else
Label3.Caption = "输入错误"
End If
End Sub
① ②