Przeliczanie walut

Transkrypt

Przeliczanie walut
Przeliczanie walut
frmWaluta
lblData
txtDolar
txtMarka
txtKorona
fraPrzelicznik
optDolar
optMarka
optKorona
txtKwotaZłoty
txtWaluta
cmdPrzeliczaj
Dim sngDolar As Single
Dim sngMarka As Single
Dim sngKorona As Single
Dim sngKwotaZłoty As Single
Dim sngWynik As Single
Dim intWybórWaluty As Integer
'Przeliczanie kwoty w złotówkach na kwotę w walucie
Private Sub cmdPrzeliczaj_Click()
Select Case intWybórWaluty
Case 1
If txtDolar.Text <> "" Then
If IsNumeric(txtDolar.Text) = False Then
MsgBox ("Niepoprawna wartość kursu dolara")
txtDolar.SetFocus
ElseIf txtDolar.Text = 0 Then
MsgBox ("Niepoprawna wartość kursu dolara")
txtDolar.SetFocus
ElseIf IsNumeric(txtKwotaZłoty.Text) = False Then
MsgBox ("Niepoprawna wartość kwoty w złotych")
txtKwotaZłoty.SetFocus
Else
sngDolar = CSng(txtDolar.Text)
sngKwotaZłoty = CSng(txtKwotaZłoty.Text)
sngWynik = sngKwotaZłoty / sngDolar
txtWaluta.Text = CStr(sngWynik) + Chr(32) + "$"
End If
Else
MsgBox ("Wpisz kurs dolara amerykańskiego w złotych")
txtDolar.SetFocus
End If
Case 2
If txtMarka.Text <> "" Then
If IsNumeric(txtMarka.Text) = False Then
MsgBox ("Niepoprawna wartość kursu marki")
txtMarka.SetFocus
ElseIf txtMarka.Text = 0 Then
MsgBox ("Niepoprawna wartość kursu marki")
txtMarka.SetFocus
ElseIf IsNumeric(txtKwotaZłoty.Text) = False Then
MsgBox ("Niepoprawna wartość kwoty w złotych")
txtKwotaZłoty.SetFocus
Else
sngMarka = CSng(txtMarka.Text)
sngKwotaZłoty = CSng(txtKwotaZłoty.Text)
sngWynik = sngKwotaZłoty / sngMarka
txtWaluta.Text = Format(sngWynik, "Fixed") + Chr(32) + "DM"
End If
Else
MsgBox ("Wpisz kurs marki niemieckiej w złotych")
txtMarka.SetFocus
End If
Case Else
If txtKorona.Text <> "" Then
If IsNumeric(txtKorona.Text) = False Then
MsgBox ("Niepoprawna wartość kursu korony")
txtKorona.SetFocus
ElseIf txtKorona.Text = 0 Then
MsgBox ("Niepoprawna wartość kursu korony")
txtKorona.SetFocus
ElseIf IsNumeric(txtKwotaZłoty.Text) = False Then
MsgBox ("Niepoprawna wartość kwoty w złotych")
txtKwotaZłoty.SetFocus
Else
sngKorona = CSng(txtKorona.Text)
sngKwotaZłoty = CSng(txtKwotaZłoty.Text)
sngWynik = sngKwotaZłoty / sngKorona
txtWaluta.Text = CStr(sngWynik) + Chr(32) + "CSK"
End If
Else
MsgBox ("Wpisz kurs korony czeskiej w złotych")
txtKorona.SetFocus
End If
End Select
End Sub
'Autoamtyczne wyświetlanie daty w tytule etykiety lblData
Private Sub Form_Load()
lblData.BackColor = vbWhite
lblData.Caption = Date
intWybórWaluty = 1
End Sub
Private Sub optDolar_Click()
intWybórWaluty = 1
End Sub
Private Sub optMarka_Click()
intWybórWaluty = 2
End Sub
Private Sub optKorona_Click()
intWybórWaluty = 3
End Sub

Podobne dokumenty