将text中的数值转换成十六进制

来源:互联网 发布:淘宝网开网店步骤 编辑:程序博客网 时间:2024/06/03 12:54
Private Sub Command1_Click()
Cls
Dim yushu As Integer
Dim a As Integer
Dim s As String

yushu = a Mod 16
a = a \ 16

a = Int(Val(Text1.Text))
yushu = a
While a <> 0
 yushu = a Mod 16
 s = f(yushu) & s
 a = a \ 16
Wend
Print s

End Sub
Private Function f(yushu As Integer) As String
  If yushu >= 10 Then
   Select Case yushu
    Case 10
     f = "A"
    Case 11
     f = "B"
    Case 12
     f = "C"
    Case 13
     f = "D"
    Case 14
     f = "E"
    Case 15
     f = "F"
  End Select
Else
 f = yushu
End If
    
 

End Function

0 0
原创粉丝点击