Form1.vb
Public Class BankAmountInWord
Private Sub ButtonShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShow.Click
Dim amount, dummy, rev, rem1 As Integer
rev = 0
amount = CInt(TextBoxNumber.Text)
If (amount > 99999) Then
MessageBox.Show("Invalid
Amount", "Invalid Amount")
End If
dummy = amount
While (dummy <> 0)
rev = rev * 10 + dummy Mod 10
dummy = dummy \ 10
End While
MessageBox.Show("Amount In
Word")
While (rev <> 0)
rem1 = rev Mod 10
Select Case (rem1)
Case 0
TextBoxWord.Text += "Zero"
Case 1
TextBoxWord.Text += "One"
Case 2
TextBoxWord.Text += "Two"
Case 3
TextBoxWord.Text += "Three"
Case 4
TextBoxWord.Text += "Four"
Case 5
TextBoxWord.Text += "Five"
Case 6
TextBoxWord.Text += "Six"
Case 7
TextBoxWord.Text += "Seven"
Case 8
TextBoxWord.Text += "Eight"
Case 9
TextBoxWord.Text += "Nine"
End Select
rev = rev \ 10
End While
Dim den() As Integer = {1000, 500, 100, 50, 20, 10, 1}
Dim i, tot As Integer
i = 0
tot = 0
MessageBox.Show("DEMONSTRATIOON", "DEMONSTRATIOON")
While (amount <> 0)
rev = amount \ den(i)
If (rev <> 0) Then
MessageBox.Show(den(i) & "
X " & rev & " = " &
rev * den(i), "Amount Detailed")
tot = tot + rev
End If
amount = amount Mod den(i)
i = i + 1
End While
MessageBox.Show("Total Number
of Notes: " & tot, "Total")
End Sub
End Class
0 comments
Post a Comment