vb中,十六进制运算出现错误,求解决办法。

来源:百度知道 编辑:UC知道 时间:2024/07/07 04:21:59
Private Sub Command1_Click()

a = Text1.Text

s1 = Val(a)
Do
temp = s1 - Int(s1 / 16) * 16
s1 = Int(s1 / 16)
If temp < 10 Then TEMP1 = CStr(temp)
If temp = 10 Then TEMP1 = "A"
If temp = 11 Then TEMP1 = "B"
If temp = 12 Then TEMP1 = "C"
If temp = 13 Then TEMP1 = "D"
If temp = 14 Then TEMP1 = "E"
If temp = 15 Then TEMP1 = "F"
b = TEMP1 & b
Loop While s1 > 0

c= b * &HBCBDA4D

Text2.Text = c

End Sub

其中,Text1.Text中的值为 2686172163 ,我就是想把它转化成十六进制和BCBDA4D 相乘,因为它是大数,所以我用了一段函数了转成十六进制了,但是计算的时候提示 “类型不匹配”。该如何改写代码?如果一定要用十六进制来运算,是否没有办法?
三楼的朋友,把它转化成十进制来运算后,变成这样的 5.31617831953e+017,数据再到后面运算就不准确了,我已经找到了大数乘法的代码了,最后运算到984024606945088603197,用这个数来求余,又不知道怎么办了。
大数求余,应该怎么做呢?
最后一楼的朋友,我已经hi你了,大数求余的vb代码,谁能给我一个呢,谢谢!

给你上传了大数求余源代码示例,请下载:
http://www.fileurls.com/download.ashx?id=trmtfy

'注:参与计算的均为10进制数字。

Private Sub Command1_Click()

a = Text1.Text
s1 = Val(a)
'B = Bhex(s1)
C = CLng(&HBCBDA4D)
D = s1 * C
D = Bhex(D)

Text2.Text = D

End Sub
'760AF99FDD31AE7
Function Bhex(ByVal Bint) As String
Do
temp = Bint - Int(Bint / 16) * 16
Bint = Int(Bint / 16)
If temp < 10 Then TEMP1 = CStr(temp)
If temp = 10 Then TEMP1 = "A"
If temp = 11 Then TEMP1 = "B"
If temp = 12 Then TEMP1 = "C"
If temp = 13 Then TEMP1 = "D"
If temp = 14 Then TEMP1 = "E"
If temp = 15 Then TEMP1 = "F"
Bhex = TEMP1 & Bhex
Loop While Bint > 0
Bhex = "&H" & Bhex

End Function
把十六进制的转换成10进制