Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'F-conv
- Dim x, y, Ans As Integer : Dim Iris As String = ""
- x = Val(TextBox1.Text) : y = Val(Mid(TextBox2.Text, 1, 1))
- If x < 16 Or x > 52 Or y < 1 Or y > 8 Then MsgBox("輸入錯誤", 48, "Error") : Exit Sub
- If x < 50 Then Ans = 2 ^ (x Mod 10) * y Else Ans = 2 ^ (x - 40) * y '範圍最大只到T
- If Ans >= 1024 And x < 40 Then x += 10 : Ans = Ans \ 1024
- TextBox3.Text = Ans & RetureByte(x)
- 'R-conv
- Dim x As Integer = Val(TextBox4.Text) : Dim y As Integer = Val(TextBox5.Text)
- If y > 8 Or y < 1 Or x > 32768 Or TextBox5.Text = "" Or TextBox4.Text = "" Then
- MsgBox("輸入錯誤", 48, "Error") : Exit Sub
- End If
- Dim B As String = Mid(TextBox4.Text, TextBox4.Text.Length - 1, 1)
- Dim Iris As Integer
- Select Case UCase(B)
- Case Is = "T" : Iris = 40
- Case Is = "G" : Iris = 30
- Case Is = "M" : Iris = 20
- Case Is = "K" : Iris = 10
- End Select
- If x / y < 1 Then Iris -= 10 : x *= 1024 '單位小於1所以往下 "T > G > M > L
- TextBox6.Text = CInt(Iris + Math.Log((x / y), 2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement