Results 1 to 10 of 10

Thread: Going loopy looping

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4

    Unhappy Going loopy looping

    Hi there I want to create a loop but I'm not sure how to go about it This is the contents of a file;

    13
    11
    15
    3
    7
    15
    12
    18
    20
    2

    I have 10 check boxes and I want to check 3 of them and compare the 3 boxes to the 10 places in the file and see it they fit. The checked box counts as 1 and if the check box plus a place in the file is greater than 20 then I want an error message. e.g if I check box number 9 then there will be an error message as there is already 20 places in number 9 and if I check box number 8 then that's ok because it makes 8th place 19 The problem is all three check boxes have to be checked and if only one of them is greater than 20 when added to a place in the file then an error message will appear
    Any ideas on how I might achieve this
    Thanks for any replies

  2. #2
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    This sounds like a school project so I'll just give you an outline

    Open the file
    Read the contents into an array
    You will have an index from the check box that will relate to the array.
    Convert the relavant array value to integer and add 1.
    If it is bigger than 20 show your error.

    All these operation are simple and there are examples in MSDN
    and on this website on how to do all of them.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4
    Hi agmorgan Thanks for replying I'm stuck at a very basic part. I have 10 check boxes and after 3 are checked I have a Proceed button. Under this proceed button I have to make the algorithm but my brain is twisted. How would I know which 3 check boxes have been chosen? For instance the check boxes are called monmorn, monafternoon, tuemorn, tueafternoon etc thru friafternoon. I don't know how to get the 3 choices to go to some 'space' so I can refer to them in the Proceed procedure
    Any ideas

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    An easier way would to make the check boxes into an array then loop through them to find which ones have been checked. HTH

    VB Code:
    1. Dim i as Integer
    2. For i = 1 to 10
    3. If chkMyArray(i).Value = 1 then 'Check box has been checked.
    4. SelectedArray(i) = i
    5. End if
    6. Next i

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4
    Hey lintz That looks cool Do I call all the boxes chkMyArray in a module like this:

    Gobal chkMyArray (10) As Integer


    And then behind each check box I just name it chkMyArray?


    Last edited by sluefoot; Apr 22nd, 2004 at 08:56 AM.

  6. #6
    Addicted Member JRSofty's Avatar
    Join Date
    Jan 2004
    Location
    Somewhere in Germany
    Posts
    149
    Not global

    If you want to make a global variable you declare it public for example

    VB Code:
    1. Public MyCheckBoxes(10) as Long

  7. #7
    Addicted Member JRSofty's Avatar
    Join Date
    Jan 2004
    Location
    Somewhere in Germany
    Posts
    149
    Long is a Long Integer Data type

    I think for your prog you only need Integer I just have a habit of typeing Long when I declare an integer variable.

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4
    Ah right. Integer is 32 bits and Long is an integer but 64 bits big Wow you must be doing some huge sums in your programs

  9. #9
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465
    Meh, longs are more than a little useful when you are graphing trig functions... those numbers just go crazily high if you don't set bounds on the number range...

  10. #10
    Addicted Member JRSofty's Avatar
    Join Date
    Jan 2004
    Location
    Somewhere in Germany
    Posts
    149
    Originally posted by sluefoot
    Ah right. Integer is 32 bits and Long is an integer but 64 bits big Wow you must be doing some huge sums in your programs
    I like to use bit flags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width