Visual Basic 6.0

Visual Basic 6.0

Slip28

Q.1) Write a VB program to add five checkboxes at runtime which represents the hobbies,
select appropriate hobbies and display result on form. [Marks 15]

Solution

Dim WithEvents Check1 As CheckBox
Dim WithEvents Check2 As CheckBox
Dim WithEvents Check3 As CheckBox
Dim WithEvents Check4 As CheckBox
Dim WithEvents Check5 As CheckBox
Dim WithEvents cmd As CommandButton

Private Sub Form_Load()
Set Check1 = Controls.Add("vb.checkbox", "check1")
Check1.Left = 0
Check1.Top = 1000
Check1.Caption = "TROWBALL"
Check1.Visible = True

Set Check2 = Controls.Add("vb.checkbox", "check2")
Check2.Left = 0
Check2.Top = 1400
Check2.Caption = "CRICKET"
Check2.Visible = True

Set Check3 = Controls.Add("vb.checkbox", "check3")
Check3.Left = 0
Check3.Top = 1800
Check3.Caption = "SWAMING"
Check3.Visible = True

Set Check4 = Controls.Add("vb.checkbox", "check4")
Check4.Left = 0
Check4.Top = 2200
Check4.Caption = "DANCING"
Check4.Visible = True

Set Check5 = Controls.Add("vb.checkbox", "check5")
Check5.Left = 0
Check5.Top = 2600
Check5.Caption = "READING"
Check5.Visible = True

Set cmd = Controls.Add("vb.commandbutton", "cmd")
cmd.Left = 0
cmd.Top = 3500
cmd.Caption = "OK"
cmd.Visible = True

End Sub

Private Sub cmd_click()
If Check1.Value = 1 Then
Print "TROWBALL"
End If

If Check2.Value = 1 Then
Print "CRICKET"
End If

If Check3.Value = 1 Then
Print "SWAMING"
End If

If Check4.Value = 1 Then
Print "DANCING"
End If

If Check5.Value = 1 Then
Print "READING"
End If
End Sub

Output




Q.4) Write a VB program to design Traffic signal using shape control. [Marks 25]

Solution

Private Sub Form_Load()
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
End Sub

Private Sub Timer1_Timer()
If Shape1.Visible Then
Shape2.Visible = True
Shape1.Visible = False
Shape3.Visible = False
ElseIf Shape2.Visible Then
Shape3.Visible = True
Shape1.Visible = False
Shape2.Visible = False
Else
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
End If
End Sub

Output



BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post