You are on page 1of 7

MSGBOX Private Sub cmdOK_Click() If chk1.Value = vbChecked And chk2.Value = vbChecked And chk3.

Value = vbChecked Then MsgBox " You like reading, computer and sports " ElseIf chk1.Value = vbChecked And chk2.Value = vbChecked And chk3.Value = vbUnchecked Then MsgBox " You like reading and computer " ElseIf chk1.Value = vbChecked And chk2.Value = vbUnchecked And chk3.Value = vbUnchecked Then MsgBox " You like reading only " ElseIf chk1.Value = vbChecked And chk2.Value = vbUnchecked And chk3.Value = vbChecked Then MsgBox " You like reading and sports " ElseIf chk1.Value = vbUnchecked And chk2.Value = vbChecked And chk3.Value = vbChecked Then MsgBox " You like computer and sports " ElseIf chk1.Value = vbUnchecked And chk2.Value = vbChecked And chk3.Value = vbUnchecked Then MsgBox " You like computer only " ElseIf chk1.Value = vbUnchecked And chk2.Value = vbUnchecked And chk3.Value = vbChecked Then MsgBox " You like sports only " Else MsgBox " You have no hobby " End If End Sub

DEPRECIATION Option Explicit Dim P As Double Dim S As Double

Dim Y As Double Dim D As Double Private Sub cmd1_Click() P = Val(txt1.Text) S = Val(txt2.Text) Y = Val(txt3.Text) D = (P - S) / Y lbl4 = " The depreciation is " & D End Sub

CHECKBOX AND OPTION Private Sub Chkbold_Click() If chkBold.Value = 1 Then txtName.FontBold = True Else txtName.FontBold = False End If End Sub Private Sub chkItalic_Click() If chkItalic.Value = 1 Then txtName.FontItalic = True Else txtName.FontItalic = False End If End Sub

Private Sub chkUnderline_Click() If chkUnderline.Value = 1 Then txtName.FontUnderline = True Else txtName.FontUnderline = False End If End Sub

Private Sub cmdclear_Click() chkBold = " " chkItalic = " " chkUnderline = " " optRed = " " optBlue = " " optGreen = " " txtName = " " End Sub

Private Sub cmdexit_Click() End End Sub

Private Sub optBlue_Click() txtName.ForeColor = vbBlue

End Sub

Private Sub optGreen_Click() txtName.ForeColor = vbGreen End Sub

Private Sub optRed_Click() txtName.ForeColor = vbRed End Sub PROBLEM Option Explicit Dim l As Double Dim p As Double Dim w As Double Dim momchk1 As Double Dim momchk2 As Double

Private Sub cmd1_Click() l = Val(txt1.Text) p = Val(txt2.Text) w = Val(txt3.Text) momchk1 = p * l / 4 momchk2 = w * l ^ 2 / 8 If chk1.Value = vbChecked And chk2.Value = vbUnchecked Then txt4 = momchk1

ElseIf chk1.Value = vbUnchecked And chk2.Value = vbChecked Then txt4 = momchk2 ElseIf chk1.Value = vbUnchecked And chk2.Value = vbUnchecked Then txt4 = 0 Else txt4 = momchk1 + momchk2 End If End Sub Benefit Calculator Option Explicit Dim fee As Single

Private Sub cmdOK_Click() fee = 0

If opt1.Value = True Then fee = 500 ElseIf opt2.Value = True Then fee = 750 ElseIf opt3.Value = True Then fee = 1000 End If

MsgBox " Name: " & Combo1.Text & txt1.Text & vbCrLf _ & " SSS Number: " & txt2.Text & vbCrLf _

& " Post Code: " & txt3.Text & vbCrLf _ & " Benefit Fee Php: " & fee, vbOKOnly, "Benefit Calculator" End Sub

Private Sub Form_Load() With lbl1 .Caption = "Benefit Calculator" .FontSize = 16 .Alignment = 2 .FontBold = True .Font = "Goudy Old Style"

End With

lbltitle.FontBold = True lbltitle.ForeColor = vbBlue

lblname.FontBold = True lblname.ForeColor = vbBlue

lblSSS.FontBold = True lblSSS.ForeColor = vbBlue

lblPostcode.FontBold = True lblPostcode.ForeColor = vbBlue

Frame1.FontBold = True Frame1.ForeColor = vbBlue Frame1.FontSize = 10

With Combo1 .Text = " Please Enter Title " .AddItem " Mr. ", 0 .AddItem " Ms. ", 1 .AddItem " Mrs. ", 2 .AddItem " Dr. ", 3 .AddItem " Engr. ", 4 .AddItem " Atty.", 5 End With End Sub

You might also like