Answer to Question #186709 in Visual Basic for km ilunga

Question #186709

Pele needs a program to calculate his bank balance at the end of the month. Get his balance at the beginning of the month and his deposit and withdrawal amounts during the month. Bank costs are fixed at R55.66 per month. Calculate and display his balance at the end of the month.

What is the second step of the button calculate event procedure?


1
Expert's answer
2021-04-28T09:50:50-0400
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class mainForm
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.btnCalculate = New System.Windows.Forms.Button()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtBalanceBeginningMonth = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtDepositAmontDuringMonth = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.txtWithdrawalAmontDuringMonth = New System.Windows.Forms.TextBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.txtBankBalanceEndMonth = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'btnCalculate
        '
        Me.btnCalculate.Location = New System.Drawing.Point(234, 161)
        Me.btnCalculate.Name = "btnCalculate"
        Me.btnCalculate.Size = New System.Drawing.Size(100, 23)
        Me.btnCalculate.TabIndex = 4
        Me.btnCalculate.Text = "Calculate"
        Me.btnCalculate.UseVisualStyleBackColor = True
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(19, 31)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(190, 13)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Balance at the beginning of the month:"
        '
        'txtBalanceBeginningMonth
        '
        Me.txtBalanceBeginningMonth.Location = New System.Drawing.Point(234, 28)
        Me.txtBalanceBeginningMonth.Name = "txtBalanceBeginningMonth"
        Me.txtBalanceBeginningMonth.Size = New System.Drawing.Size(100, 20)
        Me.txtBalanceBeginningMonth.TabIndex = 1
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(19, 57)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(160, 13)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "Deposit amont during the month:"
        '
        'txtDepositAmontDuringMonth
        '
        Me.txtDepositAmontDuringMonth.Location = New System.Drawing.Point(234, 54)
        Me.txtDepositAmontDuringMonth.Name = "txtDepositAmontDuringMonth"
        Me.txtDepositAmontDuringMonth.Size = New System.Drawing.Size(100, 20)
        Me.txtDepositAmontDuringMonth.TabIndex = 2
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(19, 83)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(177, 13)
        Me.Label3.TabIndex = 1
        Me.Label3.Text = "Withdrawal amont during the month:"
        '
        'txtWithdrawalAmontDuringMonth
        '
        Me.txtWithdrawalAmontDuringMonth.Location = New System.Drawing.Point(234, 80)
        Me.txtWithdrawalAmontDuringMonth.Name = "txtWithdrawalAmontDuringMonth"
        Me.txtWithdrawalAmontDuringMonth.Size = New System.Drawing.Size(100, 20)
        Me.txtWithdrawalAmontDuringMonth.TabIndex = 3
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(19, 119)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(177, 13)
        Me.Label4.TabIndex = 1
        Me.Label4.Text = "Withdrawal amont during the month:"
        '
        'txtBankBalanceEndMonth
        '
        Me.txtBankBalanceEndMonth.Location = New System.Drawing.Point(234, 116)
        Me.txtBankBalanceEndMonth.Name = "txtBankBalanceEndMonth"
        Me.txtBankBalanceEndMonth.ReadOnly = True
        Me.txtBankBalanceEndMonth.Size = New System.Drawing.Size(100, 20)
        Me.txtBankBalanceEndMonth.TabIndex = 2
        Me.txtBankBalanceEndMonth.TabStop = False
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(355, 200)
        Me.Controls.Add(Me.txtBankBalanceEndMonth)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.txtWithdrawalAmontDuringMonth)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.txtDepositAmontDuringMonth)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.txtBalanceBeginningMonth)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.btnCalculate)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Bank balance"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents btnCalculate As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtBalanceBeginningMonth As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtDepositAmontDuringMonth As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtWithdrawalAmontDuringMonth As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtBankBalanceEndMonth As System.Windows.Forms.TextBox

End Class





Public Class mainForm


    ''' <summary>
    '''  the button calculate event procedure
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        'Step 1. Get the balance at the beginning of the month 
        Dim balanceBeginningMonth As Double
        Double.TryParse(txtBalanceBeginningMonth.Text, balanceBeginningMonth)
        'Step 2. Get the deposit amount during the month.
        Dim depositAmontDuringMonth As Double
        Double.TryParse(txtDepositAmontDuringMonth.Text, depositAmontDuringMonth)
        'Step 3. Get the withdrawal amount during the month.
        Dim withdrawalAmontDuringMonth As Double
        Double.TryParse(txtWithdrawalAmontDuringMonth.Text, withdrawalAmontDuringMonth)
        'Step 4. Calculate the balance at the end of the month.
        Dim bankBalanceEndMonth As Double = balanceBeginningMonth + depositAmontDuringMonth - withdrawalAmontDuringMonth
        'Step 5. Display the balance at the end of the month.
        txtBankBalanceEndMonth.Text = "R" + bankBalanceEndMonth.ToString("N2")
    End Sub
End Class








What is the second step of the button calculate event procedure?


Answer:

Step 2. Get the deposit amount during the month.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS