|
-
Apr 25th, 2000, 01:14 AM
#1
Thread Starter
Lively Member
Please tell me there's a way to do this other than using a
bunch of If statements. What I'm looking for is a way to do
what "continue" does in C.
I have a text file I've read into an array of strings, each
element of teh array is a line in the file. for some lines,
I only need to do minimal things, some are even discarded.
Here's what I wanted to do
Function Parse_Lines(FileArray() As String, OptionArray() As tOption) As Boolean
Dim x As Integer, y As Integer, EndTagPos As Integer
Dim OneChar As String, KeyWord As String, FileComments As String
FileComments = ""
KeyWord = ""
For x = 1 To UBound(FileArray)
If (Mid$(FileArray(x), 1, 1) = "") Or _
Just_Spaces(FileArray(x), 1) Then
<do a "Next x" or something like that to
skip the rest>
End If
If Mid$(FileArray(x), 1, 1) = "#" Then
FileComments = FileComments & Mid$(FileArray(x), _
2, Len(FileArray(x)) & vbNewLine)
<something like a Next X>
End If
... a whole lot more string parsing...
I know you can use a whole bunch of nested If's but
that's just so damn ugly. Is there any way to start
the next iteration of the for loop without traversing the
whole loop?
-Rich
-
Apr 25th, 2000, 02:01 AM
#2
Frenzied Member
the only thing I can think of is if you do something like this
Code:
Dim i As Long
Dim j As Long
Dim boolNextIteration As Boolean
For i = 1 to 10
For j = 1 To 1
'Put Code Here
If boolNextIteration Then Exit For
'More Code Here
Next j
Next i
Hope this helps
-
Apr 25th, 2000, 02:10 AM
#3
Thread Starter
Lively Member
Thanks.. that will do the trick. I threw in a goto but I definately wasn't happy using that either. This should do. A continue statement would be much cooler though.
-
Apr 25th, 2000, 02:19 AM
#4
Hyperactive Member
May be you can use Select Case
Code:
For x = 1 To UBound(FileArray)
Select Case Mid$(FileArray(x), 1, 1)
Case ""
'....
Case "#"
'...
End Select
Next
-
Apr 25th, 2000, 06:42 AM
#5
Thread Starter
Lively Member
Switch isn't going to work out for me but it was a good idea. There are some instances where I need the first two characters and switch wont (I don't think) support that. Thanks for the suggestion though.
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
|