Private Sub Add_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
Text3.Text = Val(num1&) + Val(num2&)
End Sub
Private Sub Convert1_Click()
Dim A, B, C As String
A = Trim(Text1.Text)
B = Trim(Text7.Text)
C = Base_B_EquivOf_A(A, B)
Text4.Text = C
End Sub
Private Sub Convert2_Click()
Dim A, B, C As String
A = Trim(Text2.Text)
B = Trim(Text7.Text)
C = Base_B_EquivOf_A(A, B)
Text5.Text = C
End Sub
Private Sub Convert3_Click()
Dim A, B, C As String
A = Trim(Text3.Text)
B = Trim(Text7.Text)
C = Base_B_EquivOf_A(A, B)
Text6.Text = C
End Sub
Private Sub Divide_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
If num2& = 0 Then
MsgBox "Can't divide by zero"
Else
Text3.Text = Val(num1&) / Val(num2&)
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Multiply_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
Text3.Text = Val(num1&) * Val(num2&)
End Sub
Private Sub Subtract_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
Text3.Text = Val(num1&) - Val(num2&)
End Sub
Public Function Base_B_EquivOf_A(Dec_A, Base_B)
Dim DecVal, Accum, Radix, Qi As String
Dim Q, R
Dim i As Integer
Dim Digits As String
Digits = "0123456789ABCDEFGHIJKLMNoPQRSTUVWXYZ"
If IsNumeric(Dec_A) = False Then
Base_B_EquivOf_A = "ERROR: Argument is not an integer."
Exit Function
End If
If Val(Dec_A) = 0 Then Dec_A = 0
DecVal = CDec(Dec_A)
If Val(Base_B) = 0 Then Base_B = 0
Radix = CDec(Base_B)
If IsNumeric(DecVal) = True Then
If InStr(DecVal, ".") > 0 Then
Base_B_EquivOf_A = "ERROR: Argument is not an integer."
Exit Function
End If
End If
If Base_B <> 36 Then
Base_B_EquivOf_A = "ERROR: Base (Radix) must be in the range from 2 to 36."
Exit Function
Else
End If
Q = 1
While Q > 0
Q = DecVal / Radix
Qi = Trim(Q)
i = InStr(Qi, ".")
If i > 0 Then Qi = Left(Qi, i - 1)
R = DecVal - Radix * CDec(Qi)
Accum = Mid(Digits, R + 1, 1) & Accum
DecVal = CDec(Qi)
If Val(Qi) = 0 Then Q = 0
Wend
Base_B_EquivOf_A = Accum
End Function
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
Text3.Text = Val(num1&) + Val(num2&)
End Sub
Private Sub Convert1_Click()
Dim A, B, C As String
A = Trim(Text1.Text)
B = Trim(Text7.Text)
C = Base_B_EquivOf_A(A, B)
Text4.Text = C
End Sub
Private Sub Convert2_Click()
Dim A, B, C As String
A = Trim(Text2.Text)
B = Trim(Text7.Text)
C = Base_B_EquivOf_A(A, B)
Text5.Text = C
End Sub
Private Sub Convert3_Click()
Dim A, B, C As String
A = Trim(Text3.Text)
B = Trim(Text7.Text)
C = Base_B_EquivOf_A(A, B)
Text6.Text = C
End Sub
Private Sub Divide_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
If num2& = 0 Then
MsgBox "Can't divide by zero"
Else
Text3.Text = Val(num1&) / Val(num2&)
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Multiply_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
Text3.Text = Val(num1&) * Val(num2&)
End Sub
Private Sub Subtract_Click()
num1& = Val(Text1.Text)
num2& = Val(Text2.Text)
Text3.Text = Val(num1&) - Val(num2&)
End Sub
Public Function Base_B_EquivOf_A(Dec_A, Base_B)
Dim DecVal, Accum, Radix, Qi As String
Dim Q, R
Dim i As Integer
Dim Digits As String
Digits = "0123456789ABCDEFGHIJKLMNoPQRSTUVWXYZ"
If IsNumeric(Dec_A) = False Then
Base_B_EquivOf_A = "ERROR: Argument is not an integer."
Exit Function
End If
If Val(Dec_A) = 0 Then Dec_A = 0
DecVal = CDec(Dec_A)
If Val(Base_B) = 0 Then Base_B = 0
Radix = CDec(Base_B)
If IsNumeric(DecVal) = True Then
If InStr(DecVal, ".") > 0 Then
Base_B_EquivOf_A = "ERROR: Argument is not an integer."
Exit Function
End If
End If
If Base_B <> 36 Then
Base_B_EquivOf_A = "ERROR: Base (Radix) must be in the range from 2 to 36."
Exit Function
Else
End If
Q = 1
While Q > 0
Q = DecVal / Radix
Qi = Trim(Q)
i = InStr(Qi, ".")
If i > 0 Then Qi = Left(Qi, i - 1)
R = DecVal - Radix * CDec(Qi)
Accum = Mid(Digits, R + 1, 1) & Accum
DecVal = CDec(Qi)
If Val(Qi) = 0 Then Q = 0
Wend
Base_B_EquivOf_A = Accum
End Function