For this homework, you will create a GUI that represents a simple ATM. You’ll us
ID: 3765195 • Letter: F
Question
For this homework, you will create a GUI that represents a simple ATM. You’ll use this GUI to deposit and withdraw funds.
The screen should look similar to the following:
Your ATM GUI class should have one instance variable that contains the balance. Initially, the balance is 0. When the ‘Complete Transaction’ button is pressed, the handler should either withdraw or deposit funds from your balance variable, based upon the radio button selected. If the operation is successful, display a message dialog as shown below. If the operation is unsuccessful (overdraft), show a message dialog with the details as show below. Make sure your dialogs have titles. For a bonus (+1pt) – clear out the Entry field after any successful operation (but not on an overdraft). You’ll have to do some searching on the web to do this, but it’s not hard.
Explanation / Answer
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ia As Double = 0
Dim tb1 = Val(TextBox1.Text)
If RadioButton1.Checked = True Then
ia = ia + Val(TextBox1.Text)
MsgBox(tb1 & " was deposited", , "Success")
TextBox1.Clear()
End If
If RadioButton2.Checked = True Then
If ia = 0 Or ia < tb1 Then
MsgBox("Amount Requested :" & tb1 & " Balance:" & ia, , "Insufficient Funds")
TextBox1.Focus()
End If
ia = ia - Val(TextBox1.Text)
MsgBox(tb1 & " was withdrawn", , "Success")
TextBox1.Clear()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.