|
-
Feb 5th, 2012, 12:34 AM
#1
Thread Starter
Frenzied Member
Loop Inputbox
I have problem I used inputbox, How to loop the Xcor and Ycor inputbox untill the number of the input station
Code:
Dim stnNumber As Integer
Dim Xcor As Double
Dim Ycor As Double
stnNumber = Val(InputBox("Enter a number of station(zero to quit):", "Input station"))
Xcor = Val(InputBox("Enter a X coordinate (zero to quit): =", "Input X coordinate"))
Ycor = Val(InputBox("Enter a Y coordinate (zero to quit): =", "Input Y coordinate"))
-
Feb 5th, 2012, 01:00 AM
#2
Re: Loop Inputbox
How about a straightforward For / Next Loop ?
Code:
For I = 1 To stnNumber
<put your Inputbox statements etc here>
Next I
-
Feb 5th, 2012, 01:18 AM
#3
Thread Starter
Frenzied Member
Re: Loop Inputbox
How to terminated the program from continuing looping the program
Last edited by matrik02; Feb 5th, 2012 at 01:30 AM.
-
Feb 5th, 2012, 01:20 AM
#4
Re: Loop Inputbox
Well, if the user puts in, for example, 2 as the station number, the loop will only execute 2 times.
What code have you tried?
-
Feb 5th, 2012, 10:20 AM
#5
Re: Loop Inputbox
Matrik
Your requirements are a little vague, but Doogle
has nonetheless presented a possible approach.
Building on his loop, you possibly already have an "out" ..
namely, your "Enter a number of station(zero to quit):" .
So, one logical extension might be ...
Code:
For I = 1 To stnNumber
stnNumber = Val(InputBox("Enter a number of station(zero to quit):", "Input station"))
Xcor = Val(InputBox("Enter a X coordinate (zero to quit): =", "Input X coordinate"))
Ycor = Val(InputBox("Enter a Y coordinate (zero to quit): =", "Input Y coordinate"))Next I
If strNumber = 0 Or Xcor = 0 Or Ycor = 0 Then
Exit For
End If
Hope that gives you some ideas
Spoo
-
Feb 5th, 2012, 11:38 AM
#6
Re: Loop Inputbox
You need to read stnNumber in before you can control a loop using it !
Code:
stnNumber = Val(InputBox("Enter a number of station(zero to quit):", "Input station"))
For I = 1 To stnNumber
Xcor = Val(InputBox("Enter a X coordinate (zero to quit): =", "Input X coordinate"))
Ycor = Val(InputBox("Enter a Y coordinate (zero to quit): =", "Input Y coordinate"))
'
' do something with Xcor and Ycor
' Then go back and ask for the next values
'
Next I
'
' All Xcor and Ycor values have been read and processed
' If stnNumber was zero then the loop will not have been executed
' (no need for an If statement, although you'll need to determine
' whether any Xcor and Ycor data have been input)
'
-
Feb 5th, 2012, 01:14 PM
#7
Re: Loop Inputbox
Doogle
My bad .. 
Thank you for the catch
Spoo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|