How should i place my code?
-
oh I have a very complicated problem over here. Let me explain my application. what I will like to do in my makeExam() is actually I will random call 10 number. This 10 number are my exam question which i will get it from database. every number that ihave random call will store in a array. Before i kept in arary list,it iwll check for the repeating number. if the numExits is true mean the question have been repeated so it will exit For but if the numExits is false then it wil call the writeQuestion() where the writeQUestion() is how my application will generate the exam question according to the random number called. my application will only generate 10 question. The problem I am facing are, each time when numExits either true or false the mintActCount will always increase. This have cause the total number of question it generate less than 10 question. I trying to put a mintActCount = mintActCount - 1 when the numExits=true. But no matter where i place my mintActCount = mintActCount - 1 in my application, my application will sure hang when i run my application. Private Sub makeExam() Dim gItem As New ArrayList Dim sItem As Integer Dim numExist As Boolean Dim intQueNumber As Integer Dim bolfound As Boolean 'seed for random number Randomize(Timer) mintActCount = 0 'loop to generate 10 question gItem.Clear() Do While mintActCount <= 10 intQueNumber = CInt(Int((10 * Rnd()) + 1)) bolfound = False For Each sItem In gItem 'if the intQueNumber exist in array list If sItem = intQueNumber Then numExist = True Exit For 'when numExist = True 'I must minus 1 mintActCount, so that the total question it generate will equal to 10 'Where should i place my mintActCount=-1? Else numExist = False End If mintActCount = mintActCount - 1 Next gItem.Add(intQueNumber) If Not numExist Then Call writeQuestion(intQueNumber) End If mintActCount = mintActCount + 1 Loop End Sub -- modified at 5:14 Monday 27th March, 2006
-
oh I have a very complicated problem over here. Let me explain my application. what I will like to do in my makeExam() is actually I will random call 10 number. This 10 number are my exam question which i will get it from database. every number that ihave random call will store in a array. Before i kept in arary list,it iwll check for the repeating number. if the numExits is true mean the question have been repeated so it will exit For but if the numExits is false then it wil call the writeQuestion() where the writeQUestion() is how my application will generate the exam question according to the random number called. my application will only generate 10 question. The problem I am facing are, each time when numExits either true or false the mintActCount will always increase. This have cause the total number of question it generate less than 10 question. I trying to put a mintActCount = mintActCount - 1 when the numExits=true. But no matter where i place my mintActCount = mintActCount - 1 in my application, my application will sure hang when i run my application. Private Sub makeExam() Dim gItem As New ArrayList Dim sItem As Integer Dim numExist As Boolean Dim intQueNumber As Integer Dim bolfound As Boolean 'seed for random number Randomize(Timer) mintActCount = 0 'loop to generate 10 question gItem.Clear() Do While mintActCount <= 10 intQueNumber = CInt(Int((10 * Rnd()) + 1)) bolfound = False For Each sItem In gItem 'if the intQueNumber exist in array list If sItem = intQueNumber Then numExist = True Exit For 'when numExist = True 'I must minus 1 mintActCount, so that the total question it generate will equal to 10 'Where should i place my mintActCount=-1? Else numExist = False End If mintActCount = mintActCount - 1 Next gItem.Add(intQueNumber) If Not numExist Then Call writeQuestion(intQueNumber) End If mintActCount = mintActCount + 1 Loop End Sub -- modified at 5:14 Monday 27th March, 2006
-
oh I have a very complicated problem over here. Let me explain my application. what I will like to do in my makeExam() is actually I will random call 10 number. This 10 number are my exam question which i will get it from database. every number that ihave random call will store in a array. Before i kept in arary list,it iwll check for the repeating number. if the numExits is true mean the question have been repeated so it will exit For but if the numExits is false then it wil call the writeQuestion() where the writeQUestion() is how my application will generate the exam question according to the random number called. my application will only generate 10 question. The problem I am facing are, each time when numExits either true or false the mintActCount will always increase. This have cause the total number of question it generate less than 10 question. I trying to put a mintActCount = mintActCount - 1 when the numExits=true. But no matter where i place my mintActCount = mintActCount - 1 in my application, my application will sure hang when i run my application. Private Sub makeExam() Dim gItem As New ArrayList Dim sItem As Integer Dim numExist As Boolean Dim intQueNumber As Integer Dim bolfound As Boolean 'seed for random number Randomize(Timer) mintActCount = 0 'loop to generate 10 question gItem.Clear() Do While mintActCount <= 10 intQueNumber = CInt(Int((10 * Rnd()) + 1)) bolfound = False For Each sItem In gItem 'if the intQueNumber exist in array list If sItem = intQueNumber Then numExist = True Exit For 'when numExist = True 'I must minus 1 mintActCount, so that the total question it generate will equal to 10 'Where should i place my mintActCount=-1? Else numExist = False End If mintActCount = mintActCount - 1 Next gItem.Add(intQueNumber) If Not numExist Then Call writeQuestion(intQueNumber) End If mintActCount = mintActCount + 1 Loop End Sub -- modified at 5:14 Monday 27th March, 2006