标签:android style blog http ar io color os sp
Visual Basic版本的进制转换来了!
没有了DOS的黑框框,GUI的界面还是看着蛮舒服的。
v1.0版,只能进行简单的十进制转换。
只能进行十进制的转换那算啥、我们要的是一款可以进行多种转换的软件。
于是,进制转换迎来了它的update,v2.0版本。
v2.0的版本,可以进行16种进制能转换,想怎么转就怎么转。
v2.0 的截图:
更新日志:
v1.0 程序主体完成
v1.1 加入帮助窗口
v2.0 全新构建程序框体,增加功能
最重要的是,同Android一样,开源是必须的。
<span style="font-family:arial;font-size:12px;color:#333333;">Option Explicit Private Sub Command1_Click() Dim Dec As Long Dim Bin As String Dim Hex As String Dim Oct As String Dim H As String Dim i As Long Dim B As Long Dim D As String Dim DEC_to_BIN As String Dim DEC_to_OCT As String Dim DEC_to_HEX As String Dim BIN_to_DEC As Long Dim BIN_to_OCT As String Dim BIN_to_HEX As String Dim HEX_to_DEC As Long Dim HEX_to_BIN As String Dim OCT_to_DEC As Long Dim OCT_to_BIN As String Dim OCT_to_HEX As String Dim HEX_to_OCT As String Dim a As String If Option3.Value = True And Option5.Value = True Then '10 to 2 Dec = Text1.Text Do While Dec > 0 DEC_to_BIN = Dec Mod 2 & DEC_to_BIN Dec = Dec \ 2 Loop Text2.Text = DEC_to_BIN ElseIf Option3.Value = True And Option6.Value = True Then '10 to 8 Dec = Text1.Text Do While Dec > 0 DEC_to_OCT = Dec Mod 8 & DEC_to_OCT Dec = Dec \ 8 Loop Text2.Text = DEC_to_OCT ElseIf Option3.Value = True And Option8.Value = True Then '10 to 16 Dec = Text1.Text Do While Dec > 0 a = CStr(Dec Mod 16) Select Case a Case "10": a = "A" Case "11": a = "B" Case "12": a = "C" Case "13": a = "D" Case "14": a = "E" Case "15": a = "F" End Select DEC_to_HEX = a & DEC_to_HEX Dec = Dec \ 16 Loop Text2.Text = DEC_to_HEX ElseIf Option1.Value = True And Option7.Value = True Then '2 to 10 Bin = Text1.Text For i = 1 To Len(Bin) BIN_to_DEC = BIN_to_DEC * 2 + Val(Mid(Bin, i, 1)) Next i Text2.Text = BIN_to_DEC ElseIf Option1.Value = True And Option6.Value = True Then '2 to 8 Bin = Text1.Text If Len(Bin) Mod 3 <> 0 Then Bin = String(3 - Len(Bin) Mod 3, "0") & Bin End If For i = 1 To Len(Bin) Step 3 Select Case Mid(Bin, i, 3) Case "000": H = H & "0" Case "001": H = H & "1" Case "010": H = H & "2" Case "011": H = H & "3" Case "100": H = H & "4" Case "101": H = H & "5" Case "110": H = H & "6" Case "111": H = H & "7" End Select Next i While Left(H, 1) = "0" H = Right(H, Len(H) - 1) Wend BIN_to_OCT = H Text2.Text = BIN_to_OCT ElseIf Option1.Value = True And Option8.Value = True Then '2 to 16 Bin = Text1.Text If Len(Bin) Mod 4 <> 0 Then Bin = String(4 - Len(Bin) Mod 4, "0") & Bin End If For i = 1 To Len(Bin) Step 4 Select Case Mid(Bin, i, 4) Case "0000": H = H & "0" Case "0001": H = H & "1" Case "0010": H = H & "2" Case "0011": H = H & "3" Case "0100": H = H & "4" Case "0101": H = H & "5" Case "0110": H = H & "6" Case "0111": H = H & "7" Case "1000": H = H & "8" Case "1001": H = H & "9" Case "1010": H = H & "A" Case "1011": H = H & "B" Case "1100": H = H & "C" Case "1101": H = H & "D" Case "1110": H = H & "E" Case "1111": H = H & "F" End Select Next i While Left(H, 1) = "0" H = Right(H, Len(H) - 1) Wend BIN_to_HEX = H Text2.Text = BIN_to_HEX ElseIf Option4.Value = True And Option7.Value = True Then '16 to 10 Hex = Text1.Text For i = 1 To Len(Hex) Select Case Mid(Hex, Len(Hex) - i + 1, 1) Case "0": B = B + 16 ^ (i - 1) * 0 Case "1": B = B + 16 ^ (i - 1) * 1 Case "2": B = B + 16 ^ (i - 1) * 2 Case "3": B = B + 16 ^ (i - 1) * 3 Case "4": B = B + 16 ^ (i - 1) * 4 Case "5": B = B + 16 ^ (i - 1) * 5 Case "6": B = B + 16 ^ (i - 1) * 6 Case "7": B = B + 16 ^ (i - 1) * 7 Case "8": B = B + 16 ^ (i - 1) * 8 Case "9": B = B + 16 ^ (i - 1) * 9 Case "A": B = B + 16 ^ (i - 1) * 10 Case "B": B = B + 16 ^ (i - 1) * 11 Case "C": B = B + 16 ^ (i - 1) * 12 Case "D": B = B + 16 ^ (i - 1) * 13 Case "E": B = B + 16 ^ (i - 1) * 14 Case "F": B = B + 16 ^ (i - 1) * 15 End Select Next i HEX_to_DEC = B Text2.Text = HEX_to_DEC ElseIf Option4.Value = True And Option5.Value = True Then '16 to 2 Hex = Text1.Text For i = 1 To Len(Hex) Select Case Mid(Hex, i, 1) Case "0": B = B & "0000" Case "1": B = B & "0001" Case "2": B = B & "0010" Case "3": B = B & "0011" Case "4": B = B & "0100" Case "5": B = B & "0101" Case "6": B = B & "0110" Case "7": B = B & "0111" Case "8": B = B & "1000" Case "9": B = B & "1001" Case "A": B = B & "1010" Case "B": B = B & "1011" Case "C": B = B & "1100" Case "D": B = B & "1101" Case "E": B = B & "1110" Case "F": B = B & "1111" End Select Next i While Left(B, 1) = "0" B = Right(B, Len(B) - 1) Wend HEX_to_BIN = B Text2.Text = HEX_to_BIN ElseIf Option4.Value = True And Option6.Value = True Then '16 to 8 Hex = Text1.Text For i = 1 To Len(Hex) Select Case Mid(Hex, i, 1) Case "0": B = B & "0000" Case "1": B = B & "0001" Case "2": B = B & "0010" Case "3": B = B & "0011" Case "4": B = B & "0100" Case "5": B = B & "0101" Case "6": B = B & "0110" Case "7": B = B & "0111" Case "8": B = B & "1000" Case "9": B = B & "1001" Case "A": B = B & "1010" Case "B": B = B & "1011" Case "C": B = B & "1100" Case "D": B = B & "1101" Case "E": B = B & "1110" Case "F": B = B & "1111" End Select Next i While Left(B, 1) = "0" B = Right(B, Len(B) - 1) Wend HEX_to_BIN = B Bin = HEX_to_BIN If Len(Bin) Mod 3 <> 0 Then Bin = String(3 - Len(Bin) Mod 3, "0") & Bin End If For i = 1 To Len(Bin) Step 3 Select Case Mid(Bin, i, 3) Case "000": H = H & "0" Case "001": H = H & "1" Case "010": H = H & "2" Case "011": H = H & "3" Case "100": H = H & "4" Case "101": H = H & "5" Case "110": H = H & "6" Case "111": H = H & "7" End Select Next i While Left(H, 1) = "0" H = Right(H, Len(H) - 1) Wend BIN_to_OCT = H HEX_to_OCT = BIN_to_OCT Text2.Text = HEX_to_OCT ElseIf Option2.Value = True And Option7.Value = True Then '8 to 10 Oct = Text1.Text For i = 1 To Len(Oct) Select Case Mid(Oct, Len(Oct) - i + 1, 1) Case "0": B = B + 8 ^ (i - 1) * 0 Case "1": B = B + 8 ^ (i - 1) * 1 Case "2": B = B + 8 ^ (i - 1) * 2 Case "3": B = B + 8 ^ (i - 1) * 3 Case "4": B = B + 8 ^ (i - 1) * 4 Case "5": B = B + 8 ^ (i - 1) * 5 Case "6": B = B + 8 ^ (i - 1) * 6 Case "7": B = B + 8 ^ (i - 1) * 7 End Select Next i OCT_to_DEC = B Text2.Text = OCT_to_DEC ElseIf Option2.Value = True And Option5.Value = True Then '8 to 2 Oct = Text1.Text For i = 1 To Len(Oct) Select Case Mid(Oct, i, 1) Case "0": D = D & "000" Case "1": D = D & "001" Case "2": D = D & "010" Case "3": D = D & "011" Case "4": D = D & "100" Case "5": D = D & "101" Case "6": D = D & "110" Case "7": D = D & "111" End Select Next i While Left(D, 1) = "0" D = Right(D, Len(D) - 1) Wend OCT_to_BIN = D Text2.Text = OCT_to_BIN ElseIf Option2.Value = True And Option8.Value = True Then '8 to 16 Oct = Text1.Text For i = 1 To Len(Oct) Select Case Mid(Oct, i, 1) Case "0": D = D & "000" Case "1": D = D & "001" Case "2": D = D & "010" Case "3": D = D & "011" Case "4": D = D & "100" Case "5": D = D & "101" Case "6": D = D & "110" Case "7": D = D & "111" End Select Next i While Left(D, 1) = "0" D = Right(D, Len(D) - 1) Wend OCT_to_BIN = D Bin = OCT_to_BIN If Len(Bin) Mod 4 <> 0 Then Bin = String(4 - Len(Bin) Mod 4, "0") & Bin End If For i = 1 To Len(Bin) Step 4 Select Case Mid(Bin, i, 4) Case "0000": H = H & "0" Case "0001": H = H & "1" Case "0010": H = H & "2" Case "0011": H = H & "3" Case "0100": H = H & "4" Case "0101": H = H & "5" Case "0110": H = H & "6" Case "0111": H = H & "7" Case "1000": H = H & "8" Case "1001": H = H & "9" Case "1010": H = H & "A" Case "1011": H = H & "B" Case "1100": H = H & "C" Case "1101": H = H & "D" Case "1110": H = H & "E" Case "1111": H = H & "F" End Select Next i While Left(H, 1) = "0" H = Right(H, Len(H) - 1) Wend BIN_to_HEX = H Text2.Text = BIN_to_HEX ElseIf Option1.Value = True And Option5.Value = True Then '2 to 2 Oct = Text1.Text Text2.Text = Oct ElseIf Option2.Value = True And Option6.Value = True Then '8 to 8 Oct = Text1.Text Text2.Text = Oct ElseIf Option3.Value = True And Option7.Value = True Then '10 to 10 Oct = Text1.Text Text2.Text = Oct ElseIf Option4.Value = True And Option8.Value = True Then '16 to 16 Oct = Text1.Text Text2.Text = Oct End If End Sub Private Sub Command2_Click() Form2.Show End Sub Private Sub Command3_Click() Form3.Show End Sub </span>
下一个版本,进行软件的美化。毕竟窗口还是比较单一。
@ Mayuko
标签:android style blog http ar io color os sp
原文地址:http://blog.csdn.net/mayuko2012/article/details/41970827