skaryChinezeGuie
Well-known member
- Joined
- Apr 23, 2006
- Messages
- 94
- Programming Experience
- Beginner
I got the deposit and the withdraw to work half right. It errors out when anything other than a number is entered though because it can't convert a string to an integer. How do i prevent anything other than numbers from being entered into the textboxes, including characters like "-" ? here's my code
Private Sub BtnDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDeposit.Click
Dim myMoney As Integer = Money
Dim myBank As Integer = Bank
Dim DepositAmount As Integer = TxtDeposit.Text
If DepositAmount <= myMoney Then
Bank = myBank + DepositAmount
Money = myMoney - DepositAmount
Call FrmBank_Load(Me, New System.EventArgs)
Else
MessageBox.Show("Try Again")
End If
End Sub
Private Sub BtnWithdraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnWithdraw.Click
Dim myMoney2 As Integer = Money
Dim myBank2 As Integer = Bank
Dim WithdrawAmount As Integer = TxtWithdraw.Text
If WithdrawAmount <= myBank2 Then
Bank = myBank2 - WithdrawAmount
Money = myMoney2 + WithdrawAmount
Call FrmBank_Load(Me, New System.EventArgs)
Else
MessageBox.Show("Try Again")
End If
End Sub
Private Sub BtnDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDeposit.Click
Dim myMoney As Integer = Money
Dim myBank As Integer = Bank
Dim DepositAmount As Integer = TxtDeposit.Text
If DepositAmount <= myMoney Then
Bank = myBank + DepositAmount
Money = myMoney - DepositAmount
Call FrmBank_Load(Me, New System.EventArgs)
Else
MessageBox.Show("Try Again")
End If
End Sub
Private Sub BtnWithdraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnWithdraw.Click
Dim myMoney2 As Integer = Money
Dim myBank2 As Integer = Bank
Dim WithdrawAmount As Integer = TxtWithdraw.Text
If WithdrawAmount <= myBank2 Then
Bank = myBank2 - WithdrawAmount
Money = myMoney2 + WithdrawAmount
Call FrmBank_Load(Me, New System.EventArgs)
Else
MessageBox.Show("Try Again")
End If
End Sub