Results 1 to 5 of 5

Thread: [RESOLVED] How to check counter for particular numbers

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Resolved [RESOLVED] How to check counter for particular numbers

    When the counter is 4, 7, 10, 13, 16, 19, 22, etc, etc, etc for as many counts as needed I need to do something slightly different on those particular count values. How do I check for those values without using a bunch of If statements or a Select Case?


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to check counter for particular numbers

    Determine the pattern, and create a check based on it.

    In this case they seem to be multiples of 3, plus one... so check for that.
    Code:
    If (x - 1) Mod 3 = 0 Then
      '4 etc
    Else
      'Other numbers
    End If

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How to check counter for particular numbers

    That works and I tried it however it also includes 0 which I can overcome by just checking if number is > 1 but I was just thinking if there is a way without the additional If x > 1 Then

    x=1
    If (x - 1) Mod 3 = 0 Then


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to check counter for particular numbers

    Adding >1 is the easiest way.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How to check counter for particular numbers

    Thanks, si. I'll use your code.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

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