VB编程:我在Text1中输入一组字符:在Text2中判断,下面有详细说明
我在Text1中输入一组字符:JKLG625598A3067CF然后点Button按钮结果是忽略前4个字母,只取后面必须为16进制的字符(如果不是16进制的最好能做出提示...
我在Text1中输入一组字符:JKLG625598A3067CF 然后点Button按钮 结果是忽略前4个字母,只取后面必须为16进制的字符(如果不是16进制的最好能做出提示),在Text2中就可以了
展开
1个回答
展开全部
你自己再去改改bug吧
Private Sub Command1_Click()
Dim s_in As String
Dim s_out As String
Dim i As Integer
Dim iMax As Integer
Dim wchar As Integer
Dim bIsNum As Boolean
Dim bIs_AtoF As Boolean
Dim bIsatof As Boolean
Dim s_nothex As String
Dim s_msg As String
s_in = Text1.Text
s_out = ""
s_nothex = ""
iMax = Len(s_in)
For i = 1 To iMax
wchar = Asc(Mid(s_in, i, 1))
bIsNum = wchar >= Asc("0") And wchar <= Asc("9")
bIs_AtoF = wchar >= Asc("A") And wchar <= Asc("F")
bIsatof = wchar >= Asc("a") And wchar <= Asc("f")
If bIsNum Or bIs_AtoF Or bIsatof Then
s_out = s_out & Chr(wchar)
Else
If Len(s_nothex) = 0 Then
s_nothex = s_nothex & Chr(wchar)
End If
End If
Next
If Len(s_out) = 0 Then
If Len(s_nothex) = 0 Then
s_msg = "请不要输入空字符串!"
Else
s_msg = "没有发现十六进制字符!"
End If
MsgBox s_msg
Else
Text2.Text = s_out
End If
End Sub
Private Sub Command1_Click()
Dim s_in As String
Dim s_out As String
Dim i As Integer
Dim iMax As Integer
Dim wchar As Integer
Dim bIsNum As Boolean
Dim bIs_AtoF As Boolean
Dim bIsatof As Boolean
Dim s_nothex As String
Dim s_msg As String
s_in = Text1.Text
s_out = ""
s_nothex = ""
iMax = Len(s_in)
For i = 1 To iMax
wchar = Asc(Mid(s_in, i, 1))
bIsNum = wchar >= Asc("0") And wchar <= Asc("9")
bIs_AtoF = wchar >= Asc("A") And wchar <= Asc("F")
bIsatof = wchar >= Asc("a") And wchar <= Asc("f")
If bIsNum Or bIs_AtoF Or bIsatof Then
s_out = s_out & Chr(wchar)
Else
If Len(s_nothex) = 0 Then
s_nothex = s_nothex & Chr(wchar)
End If
End If
Next
If Len(s_out) = 0 Then
If Len(s_nothex) = 0 Then
s_msg = "请不要输入空字符串!"
Else
s_msg = "没有发现十六进制字符!"
End If
MsgBox s_msg
Else
Text2.Text = s_out
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询