1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
Option Explicit On
Option Strict On
Imports System.Globalization
Public Class MainForm
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles americanTextBox.TextChanged
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click
'converts american dollars to mexican pesos and british pounds
Const BritishRate As Decimal = 0.571505D
Const MexicanRate As Decimal = 10.7956D
Dim americanDollars As Decimal
Dim britishPounds As Decimal
Dim mexicanPesos As Decimal
Dim isconverted As Boolean
'calculate number of british pounds and mexican pesos
isconverted = Decimal.TryParse(americanTextBox.Text, _
NumberStyles.Currency, NumberFormatInfo.CurrentInfo, americanDollars)
britishPounds = americanDollars * BritishRate
mexicanPesos = americanDollars * MexicanRate
'display calculation then set focus
britishLabel.Text = britishPounds.ToString("N2")
mexicanLabel.Text = mexicanPesos.ToString("N2")
americanTextBox.Focus()
End Sub
End Class
|