我要在一个仿windows的简易计算器里加上进制转换的功能,源码如下
Dim intCurJZ As Integer '保存当前进制
Dim intLSJZ As Integer '保存历史进制
Private Function Shi2QiTa(lngYuan As Long, intJZ As Integer) As String
'进制转换10->其他进制
Dim intYuShu As Integer '保存余数
Dim strJieGuo As String '保存结果
Do While lngYuan > 0
Select Case lngYuan Mod intJZ
Case 0 To 9
strJieGuo = CStr(lngYuan Mod intJZ) + strJieGuo
Case 10 To 15
strJieGuo = Chr(Asc("A") + (lngYuan Mod intJZ) - 10) + strJieGuo
End Select
lngYuan = lngYuan \ intJZ
Loop
Shi2QiTa = strJieGuo
End Function
Private Function QiTa2Shi(strYuan As String, intJZ As Integer) As Integer
'将其他进制转换成10进制
Dim lngJieGuo As Long
Dim strTemp As String '临时字符串
Do While Len(strYuan) > 0
strTemp = Left(strYuan, 1)
Select Case strTemp
Case "0" To "9"
lngJieGuo = lngJieGuo * intJZ + CInt(strTemp)
Case "a" To "f"
lngJieGuo = lngJieGuo * intJZ + 10 + Asc(strTemp) - Asc("a")
Case "A" To "F"
lngJieGuo = lngJieGuo * intJZ + 10 + Asc(strTemp) - Asc("A")
End Select
strYuan = Right(strYuan, Len(strYuan) - 1)
Loop
QiTa2Shi = lngJieGuo
End Function
Private Sub CmdSZ_Click(Index As Integer)
TxtIN.Text = TxtIN.Text + CmdSZ(Index).Caption
End Sub
Private Sub Command1_Click(Index As Integer)
MsgBox QiTa2Shi("123", 16)
MsgBox Shi2QiTa(123, 16)
End Sub
Private Sub Form_Load()
intCurJZ = 8
intLSJZ = 8
End Sub
Private Sub OptJZ_Click(Index As Integer)
Dim intCycle As Integer
Select Case Index
Case 0
Label1.Caption = "当前进制:" + "二进制"
intLSJZ = intCurJZ
intCurJZ = 2
TxtIN.Text = Shi2QiTa(QiTa2Shi(TxtIN.Text, intLSJZ), intCurJZ)
Case 1
Label1.Caption = "当前进制:" + "八进制"
intLSJZ = intCurJZ
intCurJZ = 8
TxtIN.Text = Shi2QiTa(QiTa2Shi(TxtIN.Text, intLSJZ), intCurJZ)
Case 2
Label1.Caption = "当前进制:" + "十进制"
intLSJZ = intCurJZ
intCurJZ = 10
TxtIN.Text = Shi2QiTa(QiTa2Shi(TxtIN.Text, intLSJZ), intCurJZ)
Case 3
Label1.Caption = "当前进制:" + "十六进制"
intLSJZ = intCurJZ
intCurJZ = 16
TxtIN.Text = Shi2QiTa(QiTa2Shi(TxtIN.Text, intLSJZ), intCurJZ)
End Select
'设置0-7的数字可用
For intCycle = 0 To intCurJZ - 1
CmdSZ(intCycle).Enabled = True
Next
'设置8-9的数字不可用
For intCycle = intCurJZ To 15
CmdSZ(intCycle).Enabled = False
Next
End Sub
可是一运行就出错,谁帮我看看怎么回事