Below is the interface of the calculator:
TOOL
|
CAPTION
|
|
Label1
|
Enter principal
|
Label1
|
Label2
|
Enter rate
|
Label2
|
Label3
|
Enter time
|
Label3
|
Label4
|
lblResult
|
|
Textbox1
|
txtPrincipal
|
|
Textbox2
|
txtRate
|
|
Textbox3
|
txtTime
|
|
Command1
|
Compute
|
cmdCompute
|
Command2
|
Reset
|
cmdReset
|
Below are the code:
Dim principal As Double
Dim rate As Double
Dim time As Double
Dim interest As Double
Dim rate As Double
Dim time As Double
Dim interest As Double
Private Sub cmdcompute_Click()
principal = Val(txtprincipal.Text)
rate = Val(txtrate.Text) / 100
time = Val(txttime.Text)
interest = (p * r * t) / 100
lblresult.Caption = interest
End Sub
Private Sub cmdreset_Click()
txtprincipal.Text = " "
txtrate.Text = " "
txttime.Text = " "
lblresult.Caption = " "
End Sub
at the first step, we declare our variable using dim and give it a data type double. double has decimal point.
In the second step, we assign our variable to text box and calculate them and also display the result in lblresult (label4)
caption is the name that appear on the form.
Post a Comment