Untitled
unknown
plain_text
10 months ago
2.0 kB
6
Indexable
Public Class frmBankingSystem
Dim customerNames(100) As String
Dim accountBalances(100) As Decimal
Dim customerCount As Integer = 0 ' Counter for the number of customers
Private Sub btnAddCustomer_Click(sender As Object, e As EventArgs) Handles btnAddCustomer.Click
customerNames(customerCount) = txtCustomerName.Text
accountBalances(customerCount) = Decimal.Parse(txtAccountBalance.Text)
lstCustomers.Items.Add(txtCustomerName.Text)
customerCount += 1 ' Increment the customer count
txtCustomerName.Clear()
txtAccountBalance.Clear()
End Sub
Private Sub btnViewBalance_Click(sender As Object, e As EventArgs) Handles btnViewBalance.Click
Dim selectedIndex As Integer = lstCustomers.SelectedIndex
If selectedIndex >= 0 Then
lblBalance.Text = "Balance: " & accountBalances(selectedIndex).ToString("C")
Else
lblBalance.Text = "Please select a customer."
End If
End Sub
Private Sub btnDeposit_Click(sender As Object, e As EventArgs) Handles btnDeposit.Click
Dim selectedIndex As Integer = lstCustomers.SelectedIndex
If selectedIndex >= 0 Then
Dim depositAmount As Decimal = Decimal.Parse(InputBox("Enter deposit amount:", "Deposit"))
accountBalances(selectedIndex) += depositAmount
lblBalance.Text = "Balance: " & accountBalances(selectedIndex).ToString("C")
End If
End Sub
Private Sub btnWithdraw_Click(sender As Object, e As EventArgs) Handles btnWithdraw.Click
Dim selectedIndex As Integer = lstCustomers.SelectedIndex
If selectedIndex >= 0 Then
Dim withdrawAmount As Decimal = Decimal.Parse(InputBox("Enter withdrawal amount:", "Withdraw"))
accountBalances(selectedIndex) -= withdrawAmount
lblBalance.Text = "Balance: " & accountBalances(selectedIndex).ToString("C")
End If
End Sub
End Class
Editor is loading...
Leave a Comment