02-22-2003, 03:15 AM | #1 |
Jack Burton
Join Date: November 10, 2001
Location: Bathurst & Orange, in constant flux
Age: 37
Posts: 5,452
|
Is it possible to tell VB to repeat an action x times, based on user input ??
As in, have 1 select statement, and tell VB to run it Val(txt1.Text) times ?? |
02-22-2003, 05:32 AM | #2 |
Harper
Join Date: October 2, 2001
Location: Aberdeen, Scotland
Age: 42
Posts: 4,774
|
FOR statement. I cant remember the precise syntax (go download Delphi or C++ or somethings *sophisticaed* will you) but its something along the lines of:
code:For x = 0 to txt1.text DO[/QUOTE]
__________________
[img]\"http://www.sighost.us/members/Zvijer/andrewas.gif\" alt=\" - \" /> |
02-22-2003, 06:20 AM | #3 |
Lord Ao
Join Date: June 24, 2002
Location: Nevernever Land
Age: 50
Posts: 2,002
|
The syntax is:
code:for x = 0 to txt1.value (or .text)[/QUOTE]
__________________
[url]\"http://www.duryea.org/pinky/gurkin.wav\" target=\"_blank\">AYPWIP?</a> .... <img border=\"0\" alt=\"[1ponder]\" title=\"\" src=\"graemlins/1ponder.gif\" /> <br />\"I think so Brain, but isn\'t a cucumber that small called a gherkin?\"<br /><br />Shut UP! Pinky! |
02-22-2003, 07:11 AM | #4 |
Harper
Join Date: October 2, 2001
Location: Aberdeen, Scotland
Age: 42
Posts: 4,774
|
Ah yes, FOR..NEXT. havent used BASIC in far too long.
You can also use a WHILE or UNTIL statement, but FOR is the best in this instance. The others are more versatile though. Learn em all, programming without loops gets painful.
__________________
[img]\"http://www.sighost.us/members/Zvijer/andrewas.gif\" alt=\" - \" /> |
02-22-2003, 05:07 PM | #5 |
Jack Burton
Join Date: November 10, 2001
Location: Bathurst & Orange, in constant flux
Age: 37
Posts: 5,452
|
Ok, so that will repeat the function for x times, where x = Val(txt1.text) ??
|
02-23-2003, 01:58 PM | #6 |
Lord Ao
Join Date: June 24, 2002
Location: Nevernever Land
Age: 50
Posts: 2,002
|
you won't need the val function. VB does implicit type conversions. You can use any control for input, you are not restriced to text boxes.
Oooppps I'm sorry. Your loop will run x+1 times. Change for x = 0 to for x=1. That will run x times.
__________________
[url]\"http://www.duryea.org/pinky/gurkin.wav\" target=\"_blank\">AYPWIP?</a> .... <img border=\"0\" alt=\"[1ponder]\" title=\"\" src=\"graemlins/1ponder.gif\" /> <br />\"I think so Brain, but isn\'t a cucumber that small called a gherkin?\"<br /><br />Shut UP! Pinky! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Visual BASIC Questions | LennonCook | General Conversation Archives (11/2000 - 01/2005) | 7 | 10-21-2003 10:31 AM |
Visual Basic Decompiter | Intrepid | General Conversation Archives (11/2000 - 01/2005) | 6 | 09-04-2003 03:02 AM |
(Yet Another) Visual BASIC Question | LennonCook | General Conversation Archives (11/2000 - 01/2005) | 1 | 05-07-2003 07:59 AM |
Anyone know Visual Basic 6 here? | Jorath Calar | General Conversation Archives (11/2000 - 01/2005) | 1 | 11-24-2001 12:57 PM |
Basic D & D question | Mels | Baldurs Gate II Archives | 2 | 12-25-2000 10:56 AM |