by Adila (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 14th September 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This is a simple program.Based on traffic signals.You can arrange all the picture in a rite place.
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
'Unallowable drop; return sign to original location
Source.Visible = True
End Sub
Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
'set sign to invisible when dragging begins
Source.Visible = False
End Sub
Private Sub Form_Load()
'center from on desktop
frmTraffic.Top = (Screen.Height - frmTraffic.Height) / 2
frmTraffic.Left = (Screen.Width - frmTraffic.Width) / 2
'set dragicons for signs
For Index = 0 To 4
imgsign(Index).DragIcon = imgsign(Index).Picture
Next
End Sub
Private Sub imgcontainer_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
'Check for correct drop ( indexes match)
If Source.Index = Index Then
'Place sign in container; increment NumCorrect%
imgcontainer(Index).Picture = Source.Picture
NumCorrect% = NumCorrect% + 1
'check for last sign
If NumCorrect% = 5 Then
'display message ; Clear signs
MsgBox "Well Done", vbExclamation, "Traffic Signs"
mnuClear_Click
End If
Else
'incorrect drop; return sign to original location
Source.Visible = True
End If
End Sub
Private Sub imgsign_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
'Unallowable drop; return sign to original location
Source.Visible = True
End Sub
Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
'Unallowable drop; return sign to original location
Source.Visible = True
End Sub
Private Sub Label2_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
'Unallowable drop; return sign to original location
Source.Visible = True
End Sub
Private Sub mnuClear_Click()
'clear containers and rest signs to original locations
For Index = 0 To 4
imgcontainer(Index).Picture = ImgBlank.Picture
imgsign(Index).Visible = True
Next
'reset counter
NumCorrect% = 0
End Sub
Private Sub mnuQuiz_Click()
Const instruction$ = "Type the letter of the correct response and click ok. " & vbNewLine & _
"Click Cancle to Skip this question." & vbNewLine & vbNewLine
Const Choice$ = vbNewLine & vbNewLine & "a. Stop" & vbNewLine & _
"b. Do Not Enter" & vbNewLine & "c. Slippery Road"
Dim QuesNum%, Question$, CorrectAnswer$, Response$
'Hide traffic form
frmTraffic.Hide
'loop for three questions
For QuesNum% = 1 To 3
'Assign value to variable Question$ and variable CorrectAnswer$
Select Case QuesNum%
Case Is = 1
Question$ = "1. Which Sign has a diamond shape?" & Choice$
CorrectAnswer$ = "C"
Case Is = 2
Question$ = "2. Which Sign has an octagonal shape?" & Choice$
CorrectAnswer$ = "A"
Case Is = 3
Question$ = "3. Which Sign has a round shape?" & Choice$
CorrectAnswer$ = "B"
End Select
Response$ = InputBox(instruction$ & Question$, "Traffic Sign Shape Quiz")
'Select Case QuesNum%
'Case Is = 1
' If Response$ = "A" Or "B" Then
'MsgBox ("ur choice is wrong")
'Else
'MsgBox ("U R RIGHT")
'End If
'End Select
'Select Case QuesNum%
'C ase Is = 2
'If Response$ = "B" Or "C" Then
'MsgBox ("ur choice is wrong")
'Else
'MsgBox ("U R RIGHT")
'End If
'End Select
'Select Case QuesNum%
' Case Is = 3
'If Response$ = "A" Or "C" Then
'MsgBox ("ur choice is wrong")
'End If
'End Select
Next
frmTraffic.Show
End Sub
Private Sub mnuShow_Click()
'move all signs to correct containers
For Index = 0 To 4
imgcontainer(Index).Picture = imgsign(Index).Picture
imgsign(Index).Visible = False
Next
End Sub
No comments have been posted about This is a simple program.Based on traffic signals.You can arrange all the picture in a rite place.. Why not be the first to post a comment about This is a simple program.Based on traffic signals.You can arrange all the picture in a rite place..