Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 34

CALENDAR/TIME DISPLAY (VISUAL BASIC 6.

0)

FORM

PROPERTIES Label = lblYear


Caption = 2019
Form 1 = frmCalendar Alignment = 2-Center
Caption = My Calendar Font Name = Trebuchet MS
Border Style = 1-Fixed Single Font Bold = True
Font Size = 24
Timer = timDisp
Interval = 1000 Label = lblNumber
Caption = 01
Label = lblDay Alignment = 2-Center
Caption = - Font Name = Arial
Font Name = Trebuchet MS Font Bold = True
Font Bold = True Font Size = 72
Font Size = 24
Label = lblMonth
Label = lblTime Caption = -
Caption = - Alignment= 2-Center
Font Name = Trebuchet MS Font Name = Trebuchet MS
Font Bold= True Font Bold = True
Font Size = 24 Font Size = 24
CODE

Option Explicit

Private Sub timDisplay_Timer()


Dim Today As Variant
Today = Now
lblDay.Caption = Format(Today, “dddd”)
lblMonth.Caption = Format(Today, “mmm”)
lblYear.Caption = Format(Today, “yyyy”)
lblNumber.Caption = Format(Today, “dd”)
lblTime.Caption = Format(Today, “hh:mm:ssampm”)

SAMPLE OUTPUT
STOPWATCH APPLICATION (VISUAL BASIC 6.0)
FORM

PROPERTIES Label 2
Caption = End Time
Form 1 = frm_Stopwatch
Border Style = 1-Fixed Single Label 3
Caption = Stopwatch Application Caption = Elapsed Time

Command 1 = cmd_Start Label 4 = lbl_Start


Caption = &Start Timing Border Style = 1-Fixed Single
Caption = [Blank]
Command 2 = cmd_End
Caption = &End Timing Label 5 = lbl_End
Border Style = 1-Fixed Single
Command 3 = cmd_exit Caption = [Blank]
Caption = E&xit
Label 6 = lbl_Elapsed
Label 1 Border Style = 1-Fixed Single
Caption = Start Time Caption = [Blank]
CODE

Option Explicit
Dim StartTimeAs Variant
Dim EndTimeAs Variant
Dim ElapsedTimeAs Variant

Private Sub cmd_End_Click()


'Find the ending time, compute the elapsed time
'Put both values in label boxes
EndTime = Now
ElapsedTime = EndTime - StartTime
lbl_End.Caption = Format(EndTime, "hh:mm:ss")
lbl_Elapsed.Caption = Format(ElapsedTime, "hh:mm:ss")
End Sub

Private Sub cmd_exit_Click()


End
End Sub

Private Sub cmd_Start_Click()


'Establsih and print starting time
StartTime = Now
lbl_Start.Caption = Format(StartTime, "hh:mm:ss")
lbl_End.Caption = ""
lbl_Elapsed.Caption = ""
End Sub

SAMPLE OUTPUT
SAVINGS ACCOUNT (VISUAL BASIC 6.0)

FORM

PROPERTIES Text 1 = txt_Deposit


Text = [Blank]
Form 1 = frm_Savings
Caption = Savings Account Text 2 = txt_Interest
Border Style = 1-Fixed Single Text = [Blank]

Label 1 Text 3 = txt_Months


Caption = Monthly Deposit Text = [Blank]

Label 2 Text 4 = txt_Final


Caption = Yearly Interest Text = [Blank]

Label 3 Command 1 = cmd_Calculate


Caption = Number of Months Caption = &Calculate

Label 4 Command 2 = cmd_exit


Caption = Final Balance Caption = E&xit
CODE

Option Explicit
Dim Deposit As Single
Dim Interest As Single
Dim Months As Single
Dim Final As Single

Private Sub cmd_Calculate_Click()


Dim IntRateAs Single
'Read Values from text box
Deposit = Val(txt_Deposit.Text)
Interest = Val(txt_Interest.Text)
IntRate = Interest / 1200
Months = Val(txt_Months.Text)
'Compute final value and put in text bos
Final = Deposit * ((1 + IntRate) ^ Months - 1) / IntRate
txt_Final.Text = Format(Final, "#####0.00")
End Sub

Private Sub cmd_exit_Click()


End
End Sub

SAMPLE OUTPUT
SAVINGS ACCOUNT: KEY TRAPPING AND DECISIONS (VISUAL BASIC 6.0)

FORM SAMPLE OUTPUT

PROPERTIES Text 1 = txt_Deposit


Text = [Blank]
Form 1 = frm_Savings
Caption = Savings Account Text 2 = txt_Interest
Border Style = 1-Fixed Single Text = [Blank]

Label 1 Text 3 = txt_Months


Caption = Monthly Deposit Text = [Blank]

Label 2 Text 4 = txt_Final


Caption = Yearly Interest Text = [Blank]

Label 3 Command 1 = cmd_Calculate


Caption = Number of Months Caption = &Calculate

Label 4 Command 2 = cmd_exit


Caption = Final Balance Caption = E&xit

Command 3 = cmd_Clear
Caption = Clear &Boxe
CODE

Option Explicit
Dim Deposit As Single
Dim Interest As Single
Dim Months As Single
Dim Final As Single
ConstvbKeyDecPt = 46

Private Sub cmd_Calculate_Click()


Dim IntRateAs Single
Dim IntNewAs Single
Dim FcnAs Single, FcnD As Single
Deposit = Val(txt_Deposit.Text)
Interest = Val(txt_Interest.Text)
IntRate = Interest / 1200
Months = Val(txt_Months.Text)
Final = Val(txt_Final.Text)
If txt_Deposit.Text = "" Then
Deposit = Final / (((1 + IntRate) ^ Months - 1) / IntRate)
txt_Deposit.Text = Format(Deposit, "#####0.00")
ElseIftxt_Interest.Text = "" Then
IntNew = (Final / (0.5 * Months * Deposit) - 1) / Months
Do
IntRate = IntNew
Fcn = (1 + IntRate) ^ Months - Final * IntRate / Deposit - 1
FcnD = Months * (1 + IntRate) ^ (Months - 1) - Final / Deposit
IntNew = IntRate - Fcn / FcnD
Loop Until Abs(IntNew - IntRate) < 0.00001 / 12
Interest = IntNew * 1200
txt_Interest.Text = Format(Interest, "###0.0")
ElseIftxt_Months.Text = "" Then
Months = Log(Final * IntRate / Deposit + 1) / Log(1 + IntRate)
txt_Months.Text = Format(Months, "###.0")
ElseIftxtFinal.Text = "" Then
Final = Deposit * ((1 + IntRate) ^ Months - 1) / IntRate
txt_Final.Text = Format(Final, "#####0.00")
End If
End Sub

Private Sub cmd_Clear_Click()


'Blank out the text boxes
txt_Deposit.Text = ""
txt_Interest.Text = ""
txt_Months.Text = ""
txt_Final.Text = ""

End Sub

Private Sub cmd_exit_Click()


End
End Sub

Private Sub txt_Deposit_KeyPress(KeyAscii As Integer)


If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyDecPt
Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub

Private Sub txt_Final_KeyPress(KeyAscii As Integer)


If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyDecPt
Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub

Private Sub txt_Interest_KeyPress(KeyAscii As Integer)


If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyDecPt
Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub

Private Sub txt_Months_KeyPress(KeyAscii As Integer)


If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyDecPt
Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
MEAN AND STANDARD DEVIATION (VISUAL BASIC 6.0)

FORM

PROPERTIES
Label 2
Form 1= frm_Stats Caption = Standard Deviation
Caption = Mean and Standard Deviation Label 3 = lbl_Mean
Command 1 = cmd_Exit Alignment = 2-Center
Caption = E&xit Back Color = &H00FFFFFF& (White)
Command 2 = cmd_Accept Border Style = 1-Fixed Single
Caption = &Accept Number Font Name = MS Sans Serif
Command 3 = cmd_Compute Font Size = 12
Caption = &Compute Label 4
Command 4 = cmd_New Caption = Mean
Caption = &New Sequence Label 5 = lbl_Number
Text Box 1 = txt_Input Alignment = 2-Center
Font Name = MS Sans Serif Back Color = &H00FFFFFF& (White)
Font Size = 12 Font Name = MS Sans Serif
Label 1 = lbl_StdDev Font Size = 12
Alignment = 2-Center Label 6
Back Color = &H00FFFFFF& (White) Caption = Enter Number
Border Style = 1-Fixed Single
Font Name = MS Sans Serif Label 7
Font Size = 12 Caption = Number of Values
CODE

Option Explicit
Dim NumValuesAs Integer
Dim SumXAs Single
Dim SumX2 As Single
ConstvbKeyMinus = 45
ConstvbKeyDecPt = 46

Private Sub cmd_Accept_Click()


Dim Value As Single
txt_Input.SetFocus
NumValues = NumValues + 1
lbl_Number.Caption = Str(NumValues)
Value = Val(txt_Input.Text)
SumX = SumX + Value
SumX2 = SumX2 + Value ^ 2
txt_Input.Text = ""
End Sub

Private Sub cmd_Compute_Click()


Dim Mean As Single
Dim StdDevAs Single
txt_Input.SetFocus
If NumValues< 2 Then
Beep
Exit Sub
End If
Mean = SumX / NumValues
lbl_Mean.Caption = Str(Mean)
StdDev = Sqr((NumValues * SumX2 - SumX ^ 2) / (NumValues * (NumValues
- 1)))
lbl_StdDev.Caption = Str(StdDev)
End Sub

Private Sub cmd_Exit_Click()


End
End Sub

Private Sub cmd_New_Click()


txt_Input.SetFocus
NumValues = 0
lbl_Number.Caption = "0"
txt_Input.Text = ""
lbl_Mean.Caption = ""
lbl_StdDev.Caption = ""
SumX = 0
SumX2 = 0
End Sub
Private Sub txt_Input_KeyPress(KeyAscii As Integer)
If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyMinus
Or KeyAscii = vbKeyDecPt Or KeyAscii = vbKeyBack Then
Exit Sub
ElseIfKeyAscii = vbKeyReturn Then
Call cmd_Accept_Click
Else
KeyAscii = 0
End If
End Sub

SAMPLE OUTPUT
FLASH CARD ADDDITION (VISUAL BASIC 6.0)

FORM

PROPERTIES Font Name = Trebuchet MS


Font Bold = True
Form 1 = frm_Add Font Size = 36
Border Style = 1-Fixed Single
Caption = Flash Card Addition Label 3
Alignment = 2-Center
Command 1 = cmd_Next Caption = Score
Caption = &Next Problem Font Name = Trebuchet MS
Enabled = False Font Size = 18

Command 2 = cmd_Exit Label 4


Caption = E&xit Alignment = 2-Center
Caption = =
Text Box 1 = txt_Answer Font Name = Trebuchet MS
Font Name = Trebuchet MS Font Size = 48
Font Size = 48
Max Length = 2 Label 5
Alignment = 2-Center
Label 1 = lbl_Message Caption = +
Alignment = 2-Center Font Name = Trebuchet MS
Back Color = &H0000FFF& (Yellow) Font Size = 48
Border Style = 1-Fixed Single
Font Name = Trebuchet MS Label 6 = lbl_Num1
Font Bold = True Alignment = 2-Center
Font Size = 24 Font Name = Trebuchet MS
Font Italic = True Font Size = 48

Label 2 = lbl_Score Label 7 = lbl_Num2


Alignment = 2-Center Alignment = 2-Center
Back Color = &H00FFFF00& (Cyan) Font Name = Trebuchet MS
Border Style = 1-Fixed Single Font Size = 4
Caption = 0
CODE

Option Explicit
Dim Sum As Integer
Dim NumProbAs Integer, NumRight As Integer

Private Sub cmd_Exit_Click()


End
End Sub

Private Sub cmd_Next_Click()


'Generate next addition problem
Dim Number1 As Integer
Dim Number2 As Integer
txt_Answer.Text = ""
NumProb = NumProb + 1
Number1 = Int(Rnd * 21)
Number2 = Int(Rnd * 21)
lbl_Num1.Caption = Format(Number1, "#0")
lbl_Num2.Caption = Format(Number2, "#0")
'Find sum
Sum = Number1 + Number2
cmd_Next.Enabled = False
txt_Answer.SetFocus
End Sub

Private Sub Form_Activate()


Call cmd_Next_Click
End Sub

Private Sub Form_Load()


Randomize Timer
NumProb = 0
NumRight = 0
End Sub

Private Sub txt_Answer_KeyPress(KeyAscii As Integer)


Dim AnsAs Integer
If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyBack
Then
Exit Sub
ElseIfKeyAscii = vbKeyReturn Then
Ans = Val(txt_Answer.Text)
If Ans = Sum Then
NumRight = NumRight + 1
lbl_Message.Caption = "That's correct!"
Else
lbl_Message.Caption = "Answer is " + Format(Sum, "#0")
End If
lbl_Score.Caption = Format(100 * NumRight / NumProb, "##0")
cmd_Next.Enabled = True
cmd_Next.SetFocus
Else
KeyAscii = 0
End If
End Sub

SAMPLE OUTPUT
LOTTO LUCKY PICK: LOTTO NUMBER GENERATOR (VISUAL BASIC 6.0)

FORM

SAMPLE OUTPUT
PROPERTIES Font Size = 12
Font Style = Bold
Form 1 = frm_Lotto
Back Color = &H00E0E0E0& Label 3 = disp_2
Border Style = 1-Fixed Single Border Style = 1-Fixed Single
Caption = Lotto Lucky Pick Caption = [Blank]
Font Name = Trebuchet MS
Label 1 Font Size = 12
Alignment = 2-Center Font Style = Bold
Back Style = 0-Transparent
Caption = LOTTO LUCKY PICK Label 4 = disp_3
Font Name = Trebuchet MS Border Style = 1-Fixed Single
Font Size = 28 Caption = [Blank]
Font Style = Bold Italic Font Name = Trebuchet MS
Font Size = 12
Command 1 = app_642 Font Style = Bold
Caption = 6/42
Font Name = Trebuchet MS
Font Size = 12
Label 5 = disp_4
Command 2 = app_649 Border Style = 1-Fixed Single
Caption = 6/49 Caption = [Blank]
Font Name = Trebuchet MS Font Name = Trebuchet MS
Font Size = 12 Font Size = 12
Font Style = Bold
Command 3 = app_655
Caption = 6/55 Label 6 = disp_5
Font Name = Trebuchet MS Border Style = 1-Fixed Single
Font Size = 12 Caption = [Blank]
Font Name = Trebuchet MS
Command 4 = app_658 Font Size = 12
Caption = 6/58 Font Style = Bold
Font Name = Trebuchet MS
Font Size = 12 Label 7 = disp_6
Border Style = 1-Fixed Single
Label 2 = disp_1 Caption = [Blank]
Border Style = 1-Fixed Single Font Name = Trebuchet MS
Caption = [Blank] Font Size = 12
Font Name = Trebuchet MS Font Style = Bold
CODE

Function GenerateRandom(min As Integer, max As Integer) As Integer


Dim rand As Integer
Dim genNumber(5) As Integer
For Counter = 0 To 5
genNumber(Counter) = 0
Next
For Counter = 0 To 5
ResetRandom:
rand = Int(max * Rnd()) + min
For CounterX = 0 To 5
If rand = genNumber(CounterX) Then
GoToResetRandom
End If
Next
genNumber(Counter) = rand
Next
Call DisplayRandomNumbers(genNumber)
End Function

Private Sub DisplayRandomNumbers(genNumber() As Integer)


ran_one.Caption = genNumber(0)
ran_two.Caption = genNumber(1)
ran_three.Caption = genNumber(2)
ran_four.Caption = genNumber(3)
ran_five.Caption = genNumber(4)
ran_six.Caption = genNumber(5)
End Sub

Private Sub app_642_Click()


Call GenerateRandom(1, 42)
End Sub

Private Sub app_649_Click()


Call GenerateRandom(1, 49)
End Sub

Private Sub app_655_Click()


Call GenerateRandom(1, 55)
End Sub

Private Sub app_658_Click()


Call GenerateRandom(1, 58)
End Sub
PASSWORD VALIDATION (VISUAL BASIC 6.0)

FORM

PROPERTIES

Form 1 = frm_Password
Border Style = 1-Fixed Single
Caption = Password Validation

Label 1
Alignment = 2-Center
Caption = Please Enter Your Password
Font Name = Trebuchet MS
Font Size = 16
Font Bold = True

Text 1 = txt_Password
Alignment = 0-Left Justify
Border Style = 1-Fixed Single
Font Name = Trebuchet MS
Font Size = 14
Tag = microsoft123
Text = [Blank]

Command 1 = cmd_Validate
Caption = &Validate

Command 2 = cmdExit
Caption = E&xit
CODE

Const TRYMAX = 3

Private Sub cmd_Validate_Click()


'This procedure checks the input password
Dim Response As Integer
Static Tries As Integer
If txt_Password.Text = txt_Password.Tag Then
'If correct, display message box
MsgBox "You've passed security!",vbOKOnly + vbExclamation, "Access
Granted"
Else
If Tries < TRYMAX Then
Tries = Tries + 1
Response = MsgBox("Incorrect password. You have reached attempt "&
Tries & " of 3.", vbRetryCancel + vbCritical, "Access Denied")
ElseIf Tries = TRYMAX Then Response = MsgBox("Maximum attempts of 3.
Program will close.",vbOKOnly + vbCritical, "Access Denied")
End
End If
If Response = vbRetry Then
txt_Password.SelStart = 0
txt_Password.SelLength = Len(txt_Password.Text)
Else
End
End If
End If
txt_Password.SetFocus
End Sub

Private Sub cmdExit_Click()


End
End Sub

Private Sub Form_Activate()


txt_Password.SetFocus
End Sub
SAMPLE OUTPUT
PIZZA ORDER (VISUAL BASIC 6.0)

FORM

PROPERTIES Option 6 = optWhere


Caption = Eat In
Form 1 = frmPizza Value = True
Border Style = 1-Fixed Single Option 7 = optWhere (Yes, create a control
Caption = Pizza Order array)
Frame 1 Caption = Take Out
Caption = Size Check Box 1 = chkTop
Frame 2 Caption = Extra Cheese
Caption = Crust Type Check Box 2 = chkTop (Yes, create a control
Frame 3 array)
Caption = Toppings Caption = Mushrooms
Option 1 = optSize Check Box 3 = chkTop
Caption = Small Caption = Black Olives
Value = True Check Box 4 = chkTop
Option 2 = optSize (Yes, create a control array) Caption = Onions
Caption = Medium Check Box 5 = chkTop
Option 3 = optSize Caption = Green Peppers
Caption = Large Check Box 6 = chkTop
Option 4 = optCrust Caption = Tomatoes
Caption = Thin Crust Command 1 = cmdBuild
Value = True Caption = &Build Pizza
Option 5 = optCrust (Yes, create a control array) Command 2 = cmdExit
Caption = Thick Crust Caption = E&xit
CODE

Option Explicit
Dim PizzaSizeAs String
Dim PizzaCrustAs String
Dim PizzaWhereAs String

Private Sub cmdBuild_Click()


'This procedure builds a message box that displays your pizza type
Dim Message As String
Dim I As Integer
Dim Toppings As Integer
Toppings = 6
Message = PizzaWhere + vbCr
Message = Message + PizzaSize + " Pizza" + vbCr
Message = Message + PizzaCrust + vbCr
For I = 0 To 5
If chkTop(I).Value = vbChecked Then
Message = Message + chkTop(I).Caption + vbCr
End If
Next I
For I = 0 To 5
If chkTop(I).Value = 0 Then
Toppings = Toppings - 1
End If
Next I
If Toppings = 0 Then
Message = Message + "Cheese Only"
End If
MsgBox Message, vbOKOnly, "Your Pizza"
End Sub

Private Sub cmdExit_Click()


End
End Sub

Private Sub cmdReset_Click()


Dim I As Integer
For I = 0 To 5
chkTop(I).Value = 0
Next I
optCrust(0).Value = True
optCrust(3).Value = False
optSize(0).Value = True
optSize(1).Value = False
optSize(2).Value = False
optWhere(0).Value = True
optWhere(1).Value = False
End Sub

Private Sub Form_Load()


'Initialize pizza parameters
PizzaSize = "Small"
PizzaCrust = "Thin Crust"
PizzaWhere = "Eat In"
End Sub

Private Sub optCrust_Click(Index As Integer)


'Read crust type
PizzaCrust = optCrust(Index).Caption
End Sub

Private Sub optSize_Click(Index As Integer)


'Read pizzasize
PizzaSize = optSize(Index).Caption
End Sub

Private Sub optWhere_Click(Index As Integer)


'Read pizza eating location
PizzaWhere = optWhere(Index).Caption
End Sub
SAMPLE OUTPUT
FLIGHT PLANNER (VISUAL BASIC 6.0)

FORM

PROPERTIES
Command 1 = cmd_Assign
Form 1 = frmFlight Caption = &Assign
Border Style = 1-Fixed Single
Caption = Flight Planner Command 2 = cmd_Exit
List 1 = lst_Cities Caption = &Assign
Sorted = True

Combo Box 1 = cb_Seat


Style = 2-Dropdown List

Combo Box 2 = cbo_Meal


Style = 1-Simple
Text = [Blank]

Label 1
Caption = Destination City

Label 2
Caption = Seat Location

Label 3
Caption = Meal Preference
CODE

Private Sub cmd_Assign_Click()


Dim Message As String
Message = "Destination: " + lst_Cities.Text + vbCr
Message = Message + "Seat Location: " + cbo_Seat.Text + vbCr
Message = Message + "Meal: " + cbo_Meal.Text + vbCr
MsgBox Message, vbOKOnly + vbInformation, "Your Assignment"
End Sub

Private Sub cmd_Exit_Click()


End
End Sub

Private Sub Form_Load()


lst_Cities.Clear
lst_Cities.AddItem "San Diego"
lst_Cities.AddItem "Los Angeles"
lst_Cities.AddItem "Orange County"
lst_Cities.AddItem "Ontario"
lst_Cities.AddItem "Bakersfield"
lst_Cities.AddItem "Oakland"
lst_Cities.AddItem "Sacarmaento"
lst_Cities.AddItem "San Jose"
lst_Cities.AddItem "San Francisco"
lst_Cities.AddItem "Eureka"
lst_Cities.AddItem "Eugene"
lst_Cities.AddItem "Port Land"
lst_Cities.AddItem "Spokane"
lst_Cities.AddItem "Seattle"
lst_Cities.ListIndex = 0
cbo_Seat.AddItem "Aisle"
cbo_Seat.AddItem "Middle"
cbo_Seat.AddItem "Window"
cbo_Seat.ListIndex = 0
cbo_Meal.AddItem "Chicken"
cbo_Meal.AddItem "Msytery Meat"
cbo_Meal.AddItem "Vegetarian"
cbo_Meal.AddItem "Kosher"
cbo_Meal.AddItem "Fruit Plate"
cbo_Meal.Text = "No Preference"
End Sub
SAMPLE OUTPUT
CUSTOMER DATABASE INPUT SCREEN (VISUAL BASIC 6.0)

FORM

PROPERTIES Command 3 = cmd_Show


Caption = &Show Profile
Form 1 = frmCustomer
Border Style = 1-Fixed Single Frame 2
Caption = Customer Profile Caption = Athletic Level
Font Name = Trebuchet MS
Command 1 = cmd_Exit Font Bold = True
Caption = E&xit Font Size = 9
Font Italic = True
Frame 1
Caption = City of Residence Option 1 = opt_Level
Font Name = Trebuchet MS Caption = Beginner
Font Bold = True Index = 3
Font Size = 9
Font Italic = True Option 2 = opt_Level
Caption = Intermediate
Combo Box 1 = cbo_City Index = 2
Sorted = True Value = True
Style = 1-Simple Combo
Option 3 = opt_Level
Command 2 = cmd_New Caption = Advanced
Caption = &New Profile Index = 1
Option 4 = optLevel Index = 3
Caption = Extreme
Index = 0 Check Box 4 = chk_Act
Caption = Biking
Frame 3 Index = 2
Caption = Sex
Font Name = Trebuchet MS Check Box 5 = chk_Act
Font Bold = True Caption = Walking
Font Size = 9 Index = 1
Font Italic = True
Check Box 6 = chk_Act
Option 5 = opt_Sex Caption = Running
Caption = Female Index = 0
Index = 0
Text Box 1 = txt_Name
Option 6 = opt_Sex Font Name = MS Sans Serif
Caption = Male Font Size = 12
Index = 0 Text = [Blank]
Value = True
Text Box 2 = txt_Age
Frame 4 Font Name = MS Sans Serif
Caption = Activities Font Size = 12
Font Name = Trebuchet MS Text = [Blank]
Font Bold= True
Font Size = 9 Label 1
Font Italic = True Caption = Name
Font Name = Trebuchet MS
Check Box 1 = chk_Act Font Bold = True
Caption = In-Line Skating Font Size = 11
Index= 5 Font Italic = True

Check Box 2 = chk_Act Label 2


Caption = Skiing Caption = Age
Index = 4 Font Name = Trebuchet MS
Font Bold = True
Check Box 3 = chk_Act Font Size = 11
Caption = Swimming Font Italic = True
CODE

Option Explicit
Dim Activity As String

Private Sub cmd_Exit_Click()


End
End Sub

Private Sub cmd_New_Click()


Dim I As Integer
txt_Name.Text = ""
txt_Age.Text = ""
For I = 0 To 5
chk_Act(I).Value = vbUnchecked
Next I
End Sub

Private Sub cmd_Show_Click()


Dim NoActAs Integer, I As Integer
Dim MsgAs String, Pronoun As String
If txt_Name.Text = "" Then
MsgBox "The profile requires a name.",vbOKOnly + vbCritical, "No Name
Entered"
Exit Sub
End If

If txt_Age.Text = "" Then


MsgBox "The profile requires an age.",vbOKOnly + vbCritical, "No Age
Entered"
Exit Sub
End If

Msg = txt_Name.Text + " is" + Str$(txt_Age.Text) + " years old. " +


vbCr
If opt_Sex(0).Value = True Then Pronoun = "He " Else Pronoun = "She "
Msg = Msg + Pronoun + "is a"
If opt_Level(3).Value = False Then Msg = Msg + "n " Else
Msg = Msg + " "
Msg = Msg + Activity + " level athlete." + vbCr
NoAct = 0
For I = 0 To 5
If chk_Act(I).Value = vbChecked Then NoAct = NoAct + 1
Next I
If NoAct> 0 Then
Msg = Msg + "Activities include:" + vbCr
For I = 0 To 5
If chk_Act(I).Value = vbChecked Then Msg = Msg + String$(10, 32) +
chk_Act(I).Caption + vbCr
Next I
Else
Msg = Msg + vbCr
End If
MsgBoxMsg, vbOKOnly, "Customer Profile"

End Sub

Private Sub Form_Load()


cbo_City.AddItem "Seattle"
cbo_City.Text = "Seattle"
cbo_City.AddItem "Belluve"
cbo_City.AddItem "Kirkland"
cbo_City.AddItem "Everett"
cbo_City.AddItem "Mercer ISland"
cbo_City.AddItem "Renton"
cbo_City.AddItem "Issaquah"
cbo_City.AddItem "Kent"
cbo_City.AddItem "Bothell"
cbo_City.AddItem "Tukwila"
cbo_City.AddItem "West Seattle"
cbo_City.AddItem "Edmonds"
cbo_City.AddItem "Tacoma"
cbo_City.AddItem "Federal Way"
cbo_City.AddItem "Burien"
cbo_City.AddItem "Seatac"
cbo_City.AddItem "Woodinville"
Activity = "Intermediate"
End Sub

Private Sub opt_Level_Click(Index As Integer)


Select Case Index
Case 0
Activity = "extreme"
Case 1
Activity = "advanced"
Case 2
Activity = "intermediate"
Case 3
Activity = "beginner"
End Select
End Sub

Private Sub txt_Age_KeyPress(KeyAscii As Integer)


If (KeyAscii>= vbKey0 And KeyAscii<= vbKey9) Or KeyAscii = vbKeyBack
Then
Exit Sub
Else
KeyAscii = 0
End If
End Sub
SAMPLE OUTPUT
OBJECT ORIENTED
PROGRAMMING
(Visual Basic 6.0)

CEIT 03 – 201A

TF 10:30am – 01:30pm

ITC110

Prof. Edwin Purisima

Group 3

Del Rosario, Lian Justine N.

Deluso, Ted Mervin D.

Florano, Kristine Joy D.C

Furia, Christian B.

Gucilatar, Mel Francis A.

You might also like