Thread: Counting within timers in Visual Basic

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    1

    Counting within timers in Visual Basic

    Hi,
    I have a small app in VB with eight buttons. These are named "fixt1_b" , "fixt2_b", "fixt3_b" and so on.
    I have a timer, and on each interval I want it to call the Click sub for the next button (fixt1_b_Click then fixt2_b_Click and so on). But I can't get this to work!

    I anyone can help me, please do as it's greatly appreciated.

    Thank you in advance,
    Killno

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Shouldn't this question be in the Visual Basic forum?

    Post your code.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Originally posted by bennyandthejets
    Shouldn't this question be in the Visual Basic forum?

    Post your code.
    If there was one, yes.

    Ask at http://www.visualbasicforum.com/

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    Private m_Count as Integer
    
    Sub Timer1_Timer()
    
    m_Count  = m_Count + 1
    
    Select case m_Count
    	case 1
    		fixt1_b_Click
    	case 2
    		fixt2_b_Click
    	case 3
    		fixt3_b_Click
    ...
    	case 8
    		fixt8_b_Click
    		m_Count = 0
    End Select
    
    End Sub
    Please make sure timer is enabled and has appropriate interval.

  5. #5
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Please get off the forum

    God, I hate VB now that I learned C++. It's messy.
    Away.

  6. #6
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Originally posted by blackrat364
    Please get off the forum

    God, I hate VB now that I learned C++. It's messy.
    I feel the same way, but I think VB .NET is more cleaner (stil not as clean as C++ though ). It's also harder to do many things than it was in 6 though.

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Come on, enough guys.

    Consider this, VB does not need the semi colons and colons that festoon our preferred language, (neither does Fortran - mine), which is smarter?

    killno:

    Follow the link given, you'll get a lot more help with your VB problem there than at CProg, which really is a C/C++ site.

    Good luck.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  3. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  4. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM