如何用VB代码将文本框中输入的16进制数求和再除以16进制的0x100,取最低8位? 5
意思就是我想用VB写个程序,在VB文本框中输入16进制数:F1DD11EDAA8823AD等(最多输入20个吧,数之间有空格),求这些数的校验和,校验和的计算方法是:输入...
意思就是我想用VB写个程序,在VB文本框中输入16进制数:F1 DD 11 ED AA 88 23 AD等(最多输入20个吧,数之间有空格),求这些数的校验和,校验和的计算方法是:输入文本框中的所有数相加再除以16进制0x100的余数。用计算式子就是:CheckSum=(F1+DD+11+ED+AA+88+23+AD)%0x100。求出的CheckSum在另外一个文本框中显示出来。请求高手们怎么用VB代码实现?
单击确定按钮,在另外一个文本框中就显示出校验值CheckSum,用VB如何实现?最好有代码,对VB不怎么懂。 展开
单击确定按钮,在另外一个文本框中就显示出校验值CheckSum,用VB如何实现?最好有代码,对VB不怎么懂。 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim Cmdarr() As String
Dim CmdLong() As Long
Dim CheckSum As Long
Dim I As Long, a As Integer
a = Len(Text1.Text) / 3 - 1
ReDim Cmdarr(0 To a) As String
ReDim CmdLong(0 To a) As Long
Cmdarr = Split(Text1.Text, " ")
For I = 0 To a
CmdLong(I) = Val(CInt("&H" & Cmdarr(I)))
CheckSum = CheckSum + CmdLong(I)
Next
text2.text = CheckSum / &H100
End Sub
Dim Cmdarr() As String
Dim CmdLong() As Long
Dim CheckSum As Long
Dim I As Long, a As Integer
a = Len(Text1.Text) / 3 - 1
ReDim Cmdarr(0 To a) As String
ReDim CmdLong(0 To a) As Long
Cmdarr = Split(Text1.Text, " ")
For I = 0 To a
CmdLong(I) = Val(CInt("&H" & Cmdarr(I)))
CheckSum = CheckSum + CmdLong(I)
Next
text2.text = CheckSum / &H100
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询