VB.NET中怎么将&H1000这个16进制换成ASC 31H,30H,30H,30H
答案:1 悬赏:20 手机版
解决时间 2021-03-13 07:10
- 提问者网友:火车头
- 2021-03-12 15:51
VB.NET中怎么将&H1000这个16进制换成ASC 31H,30H,30H,30H
最佳答案
- 五星知识达人网友:山有枢
- 2021-03-12 16:07
Public Function DEC_to_HEx(ByVal Dec As Long) As String
Dim a As String
DEC_to_HEX = ""
Do While Dec > 0
a = CStr(Dec Mod 16)
Select Case a
Case "10" : a = "A"
Case "11" : a = "B"
Case "12" : a = "C"
Case "13" : a = "D"
Case "14" : a = "E"
Case "15" : a = "F"
End Select
DEC_to_HEX = a & DEC_to_HEX
Dec = Dec 16
Loop
Return DEC_to_HEX
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s1 As String = "&H1000"
Dim str As String = ""
Dim a() As String
Dim l As Integer
l = Len(s1)
ReDim a(l - 2)
For i = 1 To l - 2
a(i) = DEC_to_HEx(Asc((Mid(s1, i + 2, 1))))
Next
For i = 1 To l - 2
str = str & a(i) & "H" & " "
Next
MsgBox(str)
End Sub运行结果:
Dim a As String
DEC_to_HEX = ""
Do While Dec > 0
a = CStr(Dec Mod 16)
Select Case a
Case "10" : a = "A"
Case "11" : a = "B"
Case "12" : a = "C"
Case "13" : a = "D"
Case "14" : a = "E"
Case "15" : a = "F"
End Select
DEC_to_HEX = a & DEC_to_HEX
Dec = Dec 16
Loop
Return DEC_to_HEX
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s1 As String = "&H1000"
Dim str As String = ""
Dim a() As String
Dim l As Integer
l = Len(s1)
ReDim a(l - 2)
For i = 1 To l - 2
a(i) = DEC_to_HEx(Asc((Mid(s1, i + 2, 1))))
Next
For i = 1 To l - 2
str = str & a(i) & "H" & " "
Next
MsgBox(str)
End Sub运行结果:
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯