十六进制.哈哈,有意思VB没有十六进制转换吗?好象只有转成10进制的.
以前我用笨办法做过任意位数的计算器,办法就是把它以字符形式一位一位地算.(够笨吧?不过无任多少位都是可以算的,只是速度上有些问题,开平方,算了一个多小时才算到小数点的几千位)
我想你也可以用我的笨方法算.
不过,正确的算法应该是以二进制算.这样速度更快(当然你得对二进制熟了).
Option Explicit
Private Sub Form_Load()
Dim STR1 As String, NUM1 As Integer, NUM2 As Integer
STR1 = Chr(2) & "00FF001101101" & Chr(3)
STR2Num STR1, NUM1, NUM2
Debug.Print "NUM1=" & Hex(NUM1) & " NUM2=" & Hex(NUM2)
End Sub
Private Sub STR2Num(ByVal STR1 As String, NUM1 As Integer, NUM2 As Integer)
'这个过程是返回两个十进制数分别放入NUM1、NUM2中
Dim Byte_D() As Byte, I As Long, K As Double
Byte_D = StrConv(STR1, vbFromUnicode)
For I = 0 To UBound(Byte_D)
K = K + Byte_D(I)
Next
STR1 = IIf(K < 16, "0" & Hex(K), Right(Hex(K), 2))
Byte_D = StrConv(STR1, vbFromUnicode)
NUM1 = Byte_D(0)
NUM2 = Byte_D(1)
End Sub