post
poster: Comrade-Sergei
description: Upgraded Currency Converter
language: Visual Basic
[download]
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
51
52
53
54
55
56
57
58
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 and now Canadian dollars and Japanese yen... yes i know theyre out of date but thats what I got...

        Const BritishRate As Decimal = 0.571505D
        Const MexicanRate As Decimal = 10.7956D
        Const CanadianRate As Decimal = 1.23679D
        Const JapaneseRate As Decimal = 112.212D
        Dim americanDollars As Decimal
        Dim britishPounds As Decimal
        Dim mexicanPesos As Decimal
        Dim canadianDollars As Decimal
        Dim japaneseYen 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
        canadianDollars = americanDollars * CanadianRate
        japaneseYen = americanDollars * JapaneseRate

        'display calculation then set focus
        britishLabel.Text = britishPounds.ToString("N2")
        mexicanLabel.Text = mexicanPesos.ToString("N2")
        canadianLabel.Text = canadianDollars.ToString("N2")
        japaneseLabel.Text = japaneseYen.ToString("N2")
        americanTextBox.Focus()


    End Sub
End Class