Go Back   CodeCall Programming Forum > Software Development > Tutorials > VB Tutorials
Register Blogs Search Today's Posts Mark Forums Read

VB Tutorials Visual Basic Tutorials and Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-2009, 05:16 PM
Logan's Avatar
Programming Professional
 
Join Date: Oct 2008
Location: Ohio, Us
Age: 13
Posts: 224
Logan will become famous soon enough
Send a message via MSN to Logan Send a message via Yahoo to Logan
VB .NET How to make a timer only go (#) amount of times

Ok, I don't have any screen shots ATM, so bear with my code-only tut.
This tutorial is for those of you with a little Visual Basic experience but are still beginners.



First off say you wanted to make your form print out a number 5 times, 1, 2, 3, 4, and 5. You think "HEY, MICROSOFT IS COOL THEY PROBABLY MADE SOMETHING WITH THE TIMER TO SET THE AMOUNT OF TIME'S IT GOES OFF!!! YEA AREN'T I SMART!!" Well, no. Sorry, but they didn't. Here's how you would do it though.


First you make a form with a single button on it, and a timer. For the button make the code...
Code:
mitymer.enabled = True
Ok now that you have that when you hit the button the timer starts. Now above the button code you need to put the declarations, or declaration in this case.

Code:
Dim thisoddnumber As Integer = 0
Now that you have the declaration, you can start the timer coding. Double click on the timer so you get to the code view and add this...

Code:
thisoddnumber = thisoddnumber + 1
If thisoddnumber = 5 then
mitymer.enabled = False
You can make the numbers anything, it doesn't really matter but you also have to change all of them accordingly. I should have the screen shots up later tonight or tomorrow. Thanks for reading, and alert me of any bugs
__________________
http://forum.codecall.net/image.php?type=sigpic&userid=17757&dateline=123284  0697

Last edited by Logan; 08-09-2009 at 11:09 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-08-2009, 08:13 AM
WingedPanther's Avatar
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 11,435
WingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud of
Re: VB .NET How to make a timer only go (#) amount of times

Nice. Isn't amazing how often a "feature" isn't really needed?
__________________
CodeCall Blog | CodeCall Wiki | Shareware
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-09-2009, 03:53 PM
Logan's Avatar
Programming Professional
 
Join Date: Oct 2008
Location: Ohio, Us
Age: 13
Posts: 224
Logan will become famous soon enough
Send a message via MSN to Logan Send a message via Yahoo to Logan
Re: VB .NET How to make a timer only go (#) amount of times

I can't edit it so I guess I'll post it down here... For the timer code, instead of

Code:
thisoddnumber = thisoddnumber + 1
If thisoddnumber > 5 then
mitymer.enabled = False
it should be

Code:
thisoddnumber = thisoddnumber + 1
Print thisoddnumber
If thisoddnumber = 5 then
mitymer.enabled = False
__________________
http://forum.codecall.net/image.php?type=sigpic&userid=17757&dateline=123284  0697
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-10-2009, 09:01 AM
Jordan's Avatar
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 24,556
Jordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to allJordan is a name known to all
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Re: VB .NET How to make a timer only go (#) amount of times

Nice little tutorial, +rep!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-10-2009, 09:17 AM
Egz0N's Avatar
Code Warrior
 
Join Date: Sep 2008
Location: Kosovo
Age: 18
Posts: 4,030
Egz0N is a glorious beacon of lightEgz0N is a glorious beacon of lightEgz0N is a glorious beacon of lightEgz0N is a glorious beacon of lightEgz0N is a glorious beacon of lightEgz0N is a glorious beacon of light
Send a message via MSN to Egz0N
Re: VB .NET How to make a timer only go (#) amount of times

nice one .. +rep
__________________

Printing ASCII Code
Array Members Counter
- My Recently Tutorials
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-10-2009, 03:34 PM
Xav's Avatar
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Re: VB .NET How to make a timer only go (#) amount of times

I have never got the Print funtion to work in .NET. I believe it is a feature of VB6 only.

Also, I look at this code:

Code:
thisoddnumber = thisoddnumber + 1
This should be written like this:

Code:
thisoddnumber += 1
Also, you have this:

Code:
If thisoddnumber = 5 then
mitymer.enabled = False
This code is inefficient and and If conditional statement is unnecessary. Consider this:

Code:
mitymer.Enabled = Not (thisoddnumber = 5)
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-10-2009, 03:39 PM
mendim.'s Avatar
Guru
 
Join Date: Nov 2008
Location: Kosovo.
Posts: 2,393
mendim. is a jewel in the roughmendim. is a jewel in the roughmendim. is a jewel in the roughmendim. is a jewel in the rough
Send a message via MSN to mendim.
Re: VB .NET How to make a timer only go (#) amount of times

Nice One .. +rep .
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-10-2009, 03:52 PM
Logan's Avatar
Programming Professional
 
Join Date: Oct 2008
Location: Ohio, Us
Age: 13
Posts: 224
Logan will become famous soon enough
Send a message via MSN to Logan Send a message via Yahoo to Logan
Re: VB .NET How to make a timer only go (#) amount of times

No Xav, I like my inefficient code. It's pretty, and nice for the n00bs.
__________________
http://forum.codecall.net/image.php?type=sigpic&userid=17757&dateline=123284  0697
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-10-2009, 03:57 PM
amrosama's Avatar
Code Warrior
/////////|||||\\\\\\\\\
 
Join Date: Aug 2007
Location: Pyramids st, Giza, Egypt
Age: 21
Posts: 8,112
amrosama is a splendid one to beholdamrosama is a splendid one to beholdamrosama is a splendid one to beholdamrosama is a splendid one to beholdamrosama is a splendid one to beholdamrosama is a splendid one to beholdamrosama is a splendid one to behold
Send a message via MSN to amrosama
Re: VB .NET How to make a timer only go (#) amount of times

very nice tiutorial
+rep when i can
__________________
im a code-warrior, see my avatar
who said arabs cant dance?
and who said arabs cant drive??!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-10-2009, 04:05 PM
Xav's Avatar
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Re: VB .NET How to make a timer only go (#) amount of times

@Logan: it isn't pretty at all. It is terrible code.

Newcomers to programming should be taught good programming technique IMO.
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB 6.0: Tutorial, How to make a GIF in your application TcM VB Tutorials 18 07-08-2009 04:55 PM
VB 6.0: Tutorial, How to Make Glass2K!! TcM VB Tutorials 17 05-01-2009 07:31 AM
make a label box in vb : help iTTaleem Visual Basic Programming 3 01-20-2008 05:06 AM
Managed C++ calling VB .net dll function pranab73 Managed C++ 0 12-25-2007 01:19 PM
How to make Dumplings ahsan16 The Lounge 2 01-11-2007 11:55 PM


All times are GMT -5. The time now is 08:16 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0