Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How should i place my code?

How should i place my code?

Scheduled Pinned Locked Moved ASP.NET
questioncssdatabasedata-structureshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LovelyHelp
    wrote on last edited by
    #1

    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

    G I 2 Replies Last reply
    0
    • L LovelyHelp

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Do it the other way around instead. Only increase the counter if you have written out a question. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • L LovelyHelp

        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

        I Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        It would be easier to do a for loop. Or put the incrementer "mintActCount++" at the beginning of the loop Nick 1 line of code equals many bugs. So don't write any!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups