-
November 19th, 2013, 02:48 AM
#1
how to break For...next Statement loop
hello guys please help me to get out of this problem
im making quiz project but im stuck for loop
example(i have 60 array form loop.. i i can't stop the loop if the user get 5 wrong or get 40 correct..
here is the sample code
Code:
intNumberOfForms = 40
frmQuizArray = Shuffle(intNumberOfForms - 1)
For i = 0 To intNumberOfForms - 1
Set frmQuiz = Forms.Add("frmQuiz" & frmQuizArrArray(i))
frm.Show vbModal
Set frm = Nothing
Next i
i want to break it or insert this code but does not work.. sorry im realy noob
Code:
If quiz.markWrong = 5 then
formfail.show
elseif quiz.markCheck = 40 then
formpassed.show
else
quiz.markWrong = quiz.markWrong
quiz.markCheck = quiz.markCheck
End if
-
November 19th, 2013, 03:39 AM
#2
Re: how to break For...next Statement loop
Use a Exit For when you want to exit the for loop... so like this..
Code:
intNumberOfForms = 40
frmQuizArray = Shuffle(intNumberOfForms - 1)
For i = 0 To intNumberOfForms - 1
Set frmQuiz = Forms.Add("frmQuiz" & frmQuizArrArray(i))
frm.Show vbModal
Set frm = Nothing
If quiz.markWrong = 5 then
formfail.show
Exit For
elseif quiz.markCheck = 40 then
formpassed.show
Exit For
End if
Next i
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
November 19th, 2013, 04:59 AM
#3
Re: how to break For...next Statement loop
Originally Posted by GremlinSA
Use a Exit For when you want to exit the for loop... so like this..
Code:
intNumberOfForms = 40
frmQuizArray = Shuffle(intNumberOfForms - 1)
For i = 0 To intNumberOfForms - 1
Set frmQuiz = Forms.Add("frmQuiz" & frmQuizArrArray(i))
frm.Show vbModal
Set frm = Nothing
If quiz.markWrong = 5 then
formfail.show
Exit For
elseif quiz.markCheck = 40 then
formpassed.show
Exit For
End if
Next i
sir thanks i try my best to understand it.. its working but sometimes its showing a debug. (object unloaded) did i mistaken using if.. else.. statement methods
-
November 25th, 2013, 07:07 AM
#4
Re: how to break For...next Statement loop
On what line do you get the error, and under what conditions?
-
November 25th, 2013, 07:18 AM
#5
Re: how to break For...next Statement loop
And you should not be using one form for each question. Place all 40 questions on one form and I think your results will be easier to accomplish and the people taking this quiz will be less likely to get lost in the forms.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|