Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

causing an iteration of a loop

Status
Not open for further replies.

CLee

Programmer
Jan 28, 2001
14
0
0
AU
I have a file I need to process as follows.
I can do an Exit Loop, but that stops the whole thing.
How can I cause an iteration of the loop to occur?

example:
do until EOF
1. read a line from the file
2. test that line so if its value = ""
go to the next line. ie next iteration of the loop
3. myvalue = my value + value
loop




 
Use labels to conditionally skip blocks of code in a loop

Code:
Do Until EOF(1) 
    Line Input #1, FileLine 
    If Len(FileLine) = 0 Then GoTo SkipThisLine 
    'If you get to this point, Then line is not blank 
    Value = Val(Trim(FileLine)) 
    MyValue = MyValue + Value 
SkipThisLine: 
Loop
Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Another way:
Do Until EOF(1)
Line Input #1, FileLine
If Len(FileLine) <> 0 Then
'If you get to this point, Then line is not blank
Value = Val(Trim(FileLine))
MyValue = MyValue + Value
End If
Loop
Rick Sprague
 
Rick, Be aware that the Val function only recognizes the dot as a decimal separator.
It is unfit to be used in international applications, which may use the comma as a decimal separator.

I suggest the use of the appropriate conversion function: CInt, Csng, CDbl, ... They do recognize international conventions. _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
I was simply using the same sample code that Ruairi used. The particular line you're talking about could have been anything; it wasn't germane to the question. Rick Sprague
 
My apologies Rick: it wasn't meant to be a personalized remarks. I did oversee Ruairi's code and I just reacted to the use of the Val function, which in this case didn't relate to the problem.

Robert _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top