初来乍到来混个脸熟 对VB编程略有基础 希望更加熟练精化
先来段进制转换把 希望有大师能发现一些不足之处还是学生所以难免会有些考虑不全的
还有就是有些阅读格式问题有点马虎希望不要介意
程序代码:
Dim r$, b%, s$, l%, K%, z%, tx$ Private Sub Command1_Click() a = Text1.Text For i = 0 To 3 If Option1(i).Value = True Then x = i If Option2(i).Value = True Then y = i Next i s = "" Select Case x Case 0 s = Text1.Text Case 1 For i = 1 To Len(a) t = Val(Mid(a, i, 1)) r = "" Do u = t Mod 2 t = Int(t / 2) r = u & r Loop Until t = 0 Do Until Len(r) Mod 3 = 0 r = "0" & r Loop s = s & r Next i Case 2 t = Val(a) Do u = t Mod 2 t = Int(t / 2) s = u & s Loop Until t = 0 Case 3 For i = 1 To Len(a) t = Mid(a, i, 1) If t >= "0" And t <= "9" Then r = "" Do u = t Mod 2 t = Int(t / 2) r = u & r Loop Until t = 0 Do Until Len(r) Mod 4 = 0 r = "0" & r Loop s = s & r Else t = Asc(t) - 55 r = "" Do u = t Mod 2 t = Int(t / 2) r = u & r Loop Until t = 0 Do Until Len(r) Mod 4 = 0 r = "0" & r Loop s = s & r End If Next i End Select tx = "" Select Case y Case 0 tx = s Case 1 Do Until Len(s) Mod 3 = 0 s = "0" & s Loop chang = Len(s) For i = 1 To chang \ 3 u = Left(s, 3) s = Right(s, Len(s) - 3) a = 0 For j = 1 To 3 a = a + Val(Mid(u, j, 1)) * (2 ^ (3 - j)) Next j tx = tx & a Next i Case 2 a = 0 For i = 1 To Len(s) a = a + Val(Mid(s, i, 1)) * 2 ^ (Len(s) - i) Next i tx = a Case 3 Do Until Len(s) Mod 4 = 0 s = "0" & s Loop chang = Len(s) For i = 1 To chang \ 4 u = Left(s, 4) s = Right(s, Len(s) - 4) a = 0 For j = 1 To 4 a = a + Val(Mid(u, j, 1)) * (2 ^ (4 - j)) Next j If a > 9 Then tx = tx & Chr(a + 55) Else tx = tx & a End If Next i End Select Text2.Text = tx End Sub Private Sub Option1_Click(Index As Integer) For i = 0 To 3 If Option1(i).Value = True Then p = i Next i Select Case p Case 0 K = 48 z = 49 Case 1 K = 48 z = 55 Case 2 K = 48 z = 57 Case 3 K = 48 z = 57 End Select End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 8 Then Exit Sub If KeyAscii < K Or KeyAscii > z Then If Option1(3).Value = True And KeyAscii >= 65 And KeyAscii <= 70 Then Exit Sub Else KeyAscii = 0 End If KeyAscii = 0 End If End Sub