
Private Sub Form_Load()
Dim t1, t2, t3, t4, t5 As String
Text1.Text = t1
Text2.Text = t2
Text3.Text = t3
Text4.Text = t4
Text5.Text = t5
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Visible = True
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Visible = False
End Sub
Private Sub Image2_Click()
Rem -----Start of Decimal to Other Bases conversion ----
Dim De, Pwr, Dvdnd, X, Base As Integer
Dim Rm, Num As String
If Option1.Value = True Then
Text2.Text = Text1.Text
Num = Text1.Text
Base = 2
Text3.Text = DecTo(Num, Base)
Base = 16
Text4.Text = DecTo(Num, Base)
Base = 8
Text5.Text = DecTo(Num, Base)
End If
Rem ********** Binary to Decimal*****************
If Option2.Value = True Then
Text3.Text = Text1.Text
Num = Text1.Text
Base = 2
Text2.Text = ToDec(Num, Base)
Num = Text2.Text
Base = 16
Text4.Text = DecTo(Num, Base)
Num = Text2.Text
Base = 8
Text5.Text = DecTo(Num, Base)
End If
If Option3.Value = True Then
Text4.Text = UCase(Text1.Text)
Num = UCase(Text1.Text)
Base = 16
Text2.Text = ToDec(Num, Base)
Num = Text2.Text
Base = 2
Text3.Text = DecTo(Num, Base)
Num = Text2.Text
Base = 8
Text5.Text = DecTo(Num, Base)
End If
If Option4.Value = True Then
Text5.Text = UCase(Text1.Text)
Num = UCase(Text1.Text)
Base = 8
Text2.Text = ToDec(Num, Base)
Num = Text2.Text
Base = 2
Text3.Text = DecTo(Num, Base)
Num = Text2.Text
Base = 16
Text4.Text = DecTo(Num, Base)
End If
End Sub
Private Sub Option1_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
Text5.Text = " "
End Sub
Private Sub Option2_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
Text5.Text = " "
End Sub
Private Sub Option3_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
Text5.Text = " "
End Sub
Private Sub Option4_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
Text5.Text = " "
End Sub
Rem a function that converts a decimal number to other bases
Function DecTo(Num, Base)
Dim RRes, Res As String
Dvdnd = Val(Num)
Do
Rmdr = Dvdnd Mod Base
If Rmdr = 10 Then
Rm = "A"
ElseIf Rmdr = 11 Then
Rm = "B"
ElseIf Rmdr = 12 Then
Rm = "C"
ElseIf Rmdr = 13 Then
Rm = "D"
ElseIf Rmdr = 14 Then
Rm = "E"
ElseIf Rmdr = 15 Then
Rm = "F"
Else
Rm = Str(Rmdr)
End If
Dvdnd = Dvdnd \ Base
RRes = RRes + Rm
Loop Until Dvdnd = 0
For X = Len(RRes) To 1 Step -1
Res = Res + Mid(RRes, X, 1)
Next
DecTo = Res
End Function
Function ToDec(Num, Base)
De = 0
For X = Len(Num) To 1 Step -1
Ch = Mid(Num, X, 1)
If Ch = "A" Then
Cx = "10"
ElseIf Ch = "B" Then
Cx = "11"
ElseIf Ch = "C" Then
Cx = "12"
ElseIf Ch = "D" Then
Cx = "13"
ElseIf Ch = "E" Then
Cx = "14"
ElseIf Ch = "F" Then
Cx = "15"
Else
Cx = Ch
End If
De = De + Val(Cx) * Base ^ Pwr
Pwr = Pwr + 1
Next
ToDec = De
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim char
char = Chr(KeyAscii)
KeyAscii = Asc(UCase(char))
End Sub