Option Explicit
Dim Sterling As Double
Dim ToConvert As Double
Dim Commission As Double
Dim DollarRate As Double
Dim YenRate As Double
Dim EuroRate As Double
Dim Converted As Double
Private Sub Form_Load()
YenRate = 12.23
DollarRate = 2.01
EuroRate = 1.75
End Sub
Private Sub cmdConvert_Click()
If txtSterling.Text = "" Then
MsgBox ("Please Enter a Sum to Convert")
txtSterling.SetFoc us
Else
Sterling = txtSterling.Text
Commission = Sterling * 0.05
ToConvert = Sterling - Commission
If optDollar.Value = True Then
Converted = ToConvert * DollarRate
lblConverted.Caption = "Total Dollars"
lblRate.Caption = "Your £" & Sterling & " was converted into $" & Converted & " at a rate of " & DollarRate & ". The Commission was £" & Commission & ". "
ElseIf optYen.Value = True Then
Converted = ToConvert * YenRate
lblConverted.Caption = "Total Yen"
lblRate.Caption = "Your £" & Sterling & " was converted into ¥" & Converted & " at a rate of " & YenRate & ". The Commission was £" & Commission & ". "
ElseIf optEuro.Value = True Then
Converted = ToConvert * EuroRate
lblConverted.Caption = "Total Euros"
lblRate.Caption = "Your £" & Sterling & " was converted into €" & Converted & " at a rate of " & EuroRate & ". The Commission was £" & Commission & ". "
Else
MsgBox ("Please Select a Currency to convert to.")
End If
txtSterling.Text = ""
txtOrigSterling.Text = Sterling
txtCommission.Text = Commission
lblCommission.Caption = "Commission at 5%"
txtRemainder.Text = ToConvert
txtConverted.Text = Converted
End If
End Sub
Private Sub cmdNew_Click()
optDollar.Value = False
optYen.Value = False
optEuro.Value = False
txtSterling.Text = ""
txtOrigSterling.Text = ""
txtCommission.Text = ""
txtRemainder.Text = ""
txtConverted.Text = ""
lblRate.Caption = ""
lblCommission = "Commission at"
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub txtSterling_Change()
End Sub
Private Sub txtSterling_KeyPress(KeyAscii As Integer)
If KeyAscii > 57 < 48 Then
MsgBox ("Sorry, Numbers only please.")
txtSterling.SetFocus
End If
End Sub
Private Sub txtSterling_Validate(Cancel As Boolean)
End Sub