Results 1 to 5 of 5

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

  1. #1
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,886

    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?
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,628

    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
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,886

    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
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,628

    Re: How to check counter for particular numbers

    Adding >1 is the easiest way.

  5. #5
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,886

    Re: How to check counter for particular numbers

    Thanks, si. I'll use your code.
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

Posting Permissions

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