Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim Min As Double = Val(TextBox1.Text) : Dim Max As Double = Val(TextBox2.Text)
- Dim UnderInt As Integer = Val(TextBox3.Text) : Dim x As String = TextBox4.Text
- If Check() = False Then MsgBox("輸入錯誤", 48, "Error") : Exit Sub
- Dim DeCode As Long = (Max - Min) * 10 ^ UnderInt '編解碼所需要的值
- Label5.Text = "Ans = "
- If InStr(TextBox4.Text, ".") = 0 Then '二進制字串轉實數
- For i = 1 To 99
- If 2 ^ i > DeCode Then
- Label5.Text &= Math.Round(Min + Convert.ToInt32(x, 2) * (Max - Min) / (2 ^ i - 1), UnderInt)
- Exit For
- End If
- Next
- Else '實數轉字串
- For i = 1 To 99
- Dim Ans As Integer = (Val(x) - Min) / (Max - Min) * (2 ^ i - 1) '逆推
- If 2 ^ i > DeCode Then Label5.Text &= Convert.ToString(Ans, 2) : Exit For
- Next
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement