10. Private Sub cmdExchange_Click()
Dim Temp As Integer
Dim A, B As Integer
A = Val(txtNum1.Text)
B = Val(txtNum2.Text)
Temp = A
A = B
B = Temp
txtNum3.Text = A
txtNum4.Text = B
End Sub
15. Private Sub cmdAverage_Click()
Dim A, B, C As Integer
Dim avg As Single
A = Val(txtMks1.Text)
B = Val(txtMks2.Text)
C = Val(txtMks3.Text)
avg = (A + B + C) / 3
txtAverage.Text = FormatNumber(avg, 2)
End Sub
16. Private Sub cmdClear_Click()
txtMks1.Text = ""
txtMks2.Text = ""
txtMks3.Text = ""
txtAverage.Text = ""
txtMks1.SetFocus
End Sub
Private Sub cmdExit_Click()
End
End Sub
17.
18.
19.
20. Private Sub cmdCalculate_Click()
Dim P, N, R, I, Total As Single
P = Val(txtPrincipal.Text)
N = Val(txtYears.Text)
R = Val(txtRate.Text)
I = P * N * R / 100
txtInterest.Text = FormatCurrency(I, 2)
txtTotal.Text = FormatCurrency(P + I, 2)
End Sub
21. Private Sub cmdClear_Click()
txtPrincipal.Text = ""
txtYears.Text = ""
txtRate.Text = ""
txtInterest.Text = ""
txtTotal.Text = ""
txtPrincipal.SetFocus
End Sub
Private Sub cmdExit_Click()
End
End Sub
22.
23.
24.
25. Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdShow_Click()
If optCommerce.Value = True Then
lblFaculty.Caption = "You selected" & " Commerce " & "Faculty "
ElseIf optArts.Value = True Then
lblFaculty.Caption = "You selected" & " Arts " & " Faculty "
ElseIf optScience.Value = True Then
lblFaculty.Caption = "You selected" & " Science " & " Faculty "
End If
End Sub
31. Private Sub cmdMax_Click()
Dim A, B, C, Max As Integer
A = Val(txtNum1.Text)
B = Val(txtNum2.Text)
C = Val(txtNum3.Text)
'first find the larger of A and B
If A > B Then
Max = A
Else
Max = B
End If
32. If C > Max Then
Max = C
End If
MsgBox "Largest Number is " & Max, vbOKOnly,
"Maximum Number"
End Sub
33.
34.
35.
36. Private Sub cmdCheck_Click()
Dim N As Integer
N = Val(txtNum.Text)
If N Mod 2 = 0 Then
MsgBox "Number entered is Even", vbOKOnly, "Message Box"
Else
MsgBox "Number entered is Odd", vbOKOnly, "Message Box"
End If
End Sub
41. Private Sub cmdCheck_Click()
Dim N As Integer
N = Val(txtNum.Text)
If N > 0 Then
MsgBox "Number entered is Positive", vbOKOnly, "Message Box"
ElseIf N < 0 Then
MsgBox "Number entered is Negative", vbOKOnly, "Message Box"
Else
MsgBox "Number entered is neither Positive nor Negative",
vbOKOnly, "Message Box"
End If
End Sub
46. Private Sub cmdCalculate_Click()
Dim I, N, Fact As Integer
Fact = 1
N = Val(txtNum.Text)
For I = 1 To N
Fact = Fact * I
Next I
MsgBox "Factorial of entered number =" & Fact, vbOKOnly,
"Message Box"
End Sub
51. Private Sub cmdCalculate_Click()
Dim I, N, Sum As Integer
Sum = 0
N = Val(txtNum.Text)
For I = 1 To N
Sum = Sum + I
Next I
MsgBox "Sum of entered number =" & Sum, vbOKOnly,
"Message Box"
End Sub
56. Private Sub cmdCalculate_Click()
Dim s As Integer
Dim i As Integer
Print "S = 22 + 24 + 26 +......+ 100" & vbCrLf & vbCrLf ;
s = 0
For i = 22 To 100 Step 2
s = s + i
Next i
Print "Sum is"; s
End Sub
61. Private Sub cmdCalculate_Click()
Dim i As Integer
Dim s As Integer
Print "Series is 10 20 30 ..... 120" & vbCrLf & vbCrLf;
s = 0
For i = 10 To 120 Step 10
s = s + i
Next i
Print "Sum is"; s
End Sub
66. Private Sub cmdcalculate_Click()
Dim I, A, T As Integer
I = 1
A = Val(txtnum.Text)
lblprint.Caption = "Table of" & Str(A) & Chr(13)
For I = 1 To 10
T = I * A
lblprint.Caption = lblprint.Caption & Str(A) & "X" & Str(I) &
"=" & Str(T) & Chr(13)
Next I
End Sub
71. Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdclear_Click()
Shape1.Visible() = False
Shape2.Visible() = False
Shape3.Visible() = False
End Sub
72. Private Sub cmdcircle_Click()
Shape1.Visible() = True
End Sub
Private Sub cmdrectangle_Click()
Shape2.Visible() = True
End Sub
Private Sub cmdsquare_Click()
Shape3.Visible() = True
End Sub
73.
74.
75.
76. Private Sub cmdage_Click()
Dim age As Single
age = DatePart("yyyy", Now) - DatePart("yyyy", CDate(txtdob))
lbl4.Caption = "Age in Years" & Str(age)
End Sub
Private Sub cmdclear_Click()
txtdob.Text = ""
txtdoj.Text = ""
End Sub
77.
78.
79.
80.
81. Private Sub optblue_Click()
txtenter.ForeColor = vbBlue
End Sub
Private Sub optcenter_Click()
txtenter.Alignment = 2
End Sub
Private Sub optgreen_Click()
txtenter.ForeColor = vbGreen
End Sub
Private Sub optleft_Click()
txtenter.Alignment = 1
End Sub
82. Private Sub optred_Click()
txtenter.ForeColor = vbRed
End Sub
Private Sub optright_Click()
txtenter.Alignment = 0
End Sub
Private Sub txtenter_Change()
txtenter.FontBold = True
End Sub