programming vb6.0 activities
DESCRIPTION
Programming Visual Basic 6.0 Activities for secondary studentsTRANSCRIPT
Private sub Timer1_Timer()
Label1.Caption = Format(Time, “hh:mm:ss”)
End Sub
Clock
Private Sub HScroll1_Change() Picture1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value) Label1.Caption = “red:” & HScroll1.ValueEnd Sub
Private Sub HScroll2_Change() Picture1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value) Label2.Caption = “green:” & HScroll2.ValueEnd Sub
Private Sub HScroll1_Change() Picture1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value) Label3.Caption = “blue:” & HScroll3.ValueEnd Sub
Color Mixer
Private Sub Command1_Click() Image1.Top = Image1.Top - 30 If Image1.Top < 1 Then Image1.Top = 1End Sub
Private Sub Command2_Click() Image1.Top = Image1.Top + 30 If Image1.Top > Form1.Height - Image1.Height Then Image1.Top = Form1.Height - Image1.Height End IfEnd Sub
Private Sub Command3_Click() Image1.Left = Image1.Left - 30 If Image1.Left < 1 Then Image1.Left = 1End Sub
Private Sub Command4_Click() Image1.Left = Image1.Left + 30 If Image1.Left > Form1.Width - Image1.Width Then Image1.Left = form4.Width - Image1.Width End IfEnd Sub
Moving Human
Tools Needed:
LabelTextCommand
Private Sub Command1_Click() frm2.Show frm1.HideEnd Sub
First Program
FORM 1
Private Sub Command1_Click()num1 = Val(Text1.Text)num2 = Val(Text2.Text)ans = num1 + num2Label3.Caption = "The sum is " & ansEnd Sub
Private Sub Command2_Click()num1 = Val(Text1.Text)num2 = Val(Text2.Text)ans = num1 - num2Label3.Caption = "The difference is " & ansEnd Sub
Private Sub Command3_Click()num1 = Val(Text1.Text)num2 = Val(Text2.Text)ans = num1 * num2Label3.Caption = "The product is " & ansEnd Sub
Private Sub Command4_Click()num1 = Val(Text1.Text)num2 = Val(Text2.Text)ans = num1 / num2Label3.Caption = "The quotient is " & ansEnd Sub
Private Sub Command5_Click()Form2.Show
Math Operators
FORM2
Form2.Label1.Caption = ansEnd Sub
Private Sub Command1_Click()Label2.Caption = ans + 3
End Sub
Dim username As StringDim password As Integer
Private Sub cmdok_Click()username = Text1.Textpassword = Val(Text2.Text)
If LCase(username) = "juan" And password = 1234 Then MsgBox ("Welcome" & username)frm2.ShowMe.HideElseMsgBox ("Invalid")Text1.Text = ""Text2.Text = ""End IfEnd Sub
Private Sub Command1_Click()Text1.Text = ""Text2.Text = ""End Sub
Private Sub Timer1_Timer()Label1.Left = Label1.Left - 360End Sub
User Password
Private Sub Combo1_Click() If Combo1.Text = "Red" Then Me.BackColor = vbRed 'me is the current form ElseIf Combo1.Text = "Green" Then Me.BackColor = vbGreen ElseIf Combo1.Text = "Yellow" Then Me.BackColor = vbYellow End IfEnd Sub
'Note: make- change to -click to automatically change the color
Private Sub Command1_Click() frm2.Width = 4000End Sub
Private Sub Command10_Click() If List1.ListIndex = 0 Then Me.BackColor = vbRed ElseIf List1.ListIndex = 1 Then Me.BackColor = vbGreen ElseIf List1.ListIndex = 2 Then Me.BackColor = vbYellowEnd IfEnd Sub
Private Sub Command2_Click() frm2.Width = 6000End Sub
Private Sub Command3_Click() frm2.Width = 8000End Sub
Private Sub Command4_Click() frm2.Height = 6450 - 2000End Sub
Private Sub Command5_Click() frm2.Height = 6000End Sub
Private Sub Command6_Click() frm2.Height = 6450 + 2000End Sub
Private Sub Command7_Click() frm1.Show frm2.HideEnd Sub
Private Sub Command8_Click() Label5.Caption = Text1.Text & " " & Text2.Text & " " & Text3.TextEnd Sub
Private Sub Command9_Click() If Combo1.Text = "Red" Then Me.BackColor = vbRed 'me is the current form ElseIf Combo1.Text = "Green" Then Me.BackColor = vbGreen ElseIf Combo1.Text = "Yellow" Then Me.BackColor = vbYellowEnd If
'using of combo box to change the color of the background of form using backcolor commandIf List1.Text = "Red" ThenMe.BackColor = vbRed 'me is the current formElseIf List1.Text = "Green" ThenMe.BackColor = vbGreenElseIf List1.Text = "Yellow" ThenMe.BackColor = vbYellowEnd IfEnd Sub
'using of list box to change the color of the background of form using backcolor commandPrivate Sub List1_Click() If List1.Text = "Red" Then Me.BackColor = vbRed 'me is the current form ElseIf List1.Text = "Green" Then Me.BackColor = vbGreen ElseIf List1.Text = "Yellow" Then Me.BackColor = vbYellow End IfEnd Sub
Private Sub Option1_Click() frm2.BackColor = vbRedEnd Sub
Private Sub Option2_Click() frm2.BackColor = vbGreenEnd Sub
Private Sub Option3_Click() frm2.BackColor = vbBlueEnd Sub