Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim 須轉換進制 As String
- Dim 十進位數字 As Integer = 0
- Dim 取出數字 As String
- Dim text As String
- Dim tmp As String = ""
- Dim ans As String = ""
- Dim ups As Integer
- Dim angel()
- Dim len1 As Integer
- If Mid(TextBox1.Text, 2, 1) = " " Then
- 須轉換進制 = Mid(TextBox1.Text, 1, 1)
- Else
- 須轉換進制 = Mid(TextBox1.Text, 1, 2)
- End If
- text = TextBox1.Text
- angel = Split(text, " ")
- 取出數字 = Val(angel(1))
- len1 = Len(取出數字)
- Select Case 須轉換進制
- Case 2
- For i = 1 To Len(取出數字)
- If (Mid(取出數字, i, 1) = "1") Then
- 十進位數字 += 2 ^ (Len(取出數字) - i)
- End If
- Next
- Case 3
- For i = 1 To Len(取出數字)
- If (Mid(取出數字, i, 1) = "1") Then
- 十進位數字 += 3 ^ (Len(取出數字) - i)
- ElseIf (Mid(取出數字, i, 1) = "2") Then
- 十進位數字 += (3 ^ (Len(取出數字) - i)) * 2
- End If
- Next
- Case 4
- Dim times As Integer = 3
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (4 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 5
- Dim times As Integer = 4
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (5 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 6
- Dim times As Integer = 5
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (6 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 7
- Dim times As Integer = 6
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (7 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 8
- Dim times As Integer = 7
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (8 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 9
- Dim times As Integer = 8
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (9 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 10
- Dim times As Integer = 9
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (10 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 11
- Dim times As Integer = 10
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (11 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 12
- Dim times As Integer = 11
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (12 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 13
- Dim times As Integer = 12
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (13 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 14
- Dim times As Integer = 13
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (14 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 15
- Dim times As Integer = 14
- For i = 1 To Len(取出數字)
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (15 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- Case 16
- Dim times As Integer = 10
- For i = 1 To Val(Len(取出數字))
- For j = 1 To times
- If (Mid(取出數字, i, 1) = j) Then
- 十進位數字 += (16 ^ (Len(取出數字) - i)) * j
- End If
- Next
- Next
- For i = len1 To 1
- ups = Asc(Mid(取出數字, i, 1))
- MsgBox(len1)
- Next
- Select Case ups
- Case 65 : 十進位數字 = 十進位數字 + 10
- Case 66 : 十進位數字 = 十進位數字 + 11
- Case 67 : 十進位數字 = 十進位數字 + 12
- Case 68 : 十進位數字 = 十進位數字 + 13
- Case 69 : 十進位數字 = 十進位數字 + 14
- Case 70 : 十進位數字 = 十進位數字 + 15
- End Select
- End Select
- Select Case angel(2)
- Case 8
- tmp = 十進位數字
- For i = Len(十進位數字) To 1
- ans = ans & (Val(tmp) Mod 8)
- tmp = Val(十進位數字) \ 8
- i = i - 1
- Next
- Case 16
- tmp = Val(十進位數字)
- Do
- Select Case tmp Mod 16
- Case Is < 10 : ans = (tmp Mod 16) & ans
- Case 10 : ans = "A" & ans
- Case 11 : ans = "B" & ans
- Case 12 : ans = "C" & ans
- Case 13 : ans = "D" & ans
- Case 14 : ans = "E" & ans
- Case 15 : ans = "F" & ans
- End Select
- tmp = tmp \ 16
- Loop Until tmp = 0
- End Select
- TextBox2.Text = ans
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement