Ironworks Gaming Forum

Ironworks Gaming Forum (http://www.ironworksforum.com/forum/index.php)
-   General Conversation Archives (11/2000 - 01/2005) (http://www.ironworksforum.com/forum/forumdisplay.php?f=28)
-   -   Visual Basic Question (http://www.ironworksforum.com/forum/showthread.php?t=84383)

LennonCook 02-22-2003 03:15 AM

<font color="lightblue">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 ?? </font>

andrewas 02-22-2003 05:32 AM

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:
</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">For x = 0 to txt1.text DO
.
.
.
LOOP</pre>[/QUOTE]

Night Stalker 02-22-2003 06:20 AM

The syntax is:

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">for x = 0 to txt1.value (or .text)
.
.
select case y
case
condition
.
.
end select
.
.
next</pre>[/QUOTE]

andrewas 02-22-2003 07:11 AM

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.

LennonCook 02-22-2003 05:07 PM

<font color="lightblue">Ok, so that will repeat the function for x times, where x = Val(txt1.text) ?? </font>

Night Stalker 02-23-2003 01:58 PM

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.


All times are GMT -4. The time now is 01:42 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved