Home All Groups Group Topic Archive Search About

Writing a blank line under an if statement

Author
4 Aug 2006 7:15 PM
monitor-radiation
I'm trying to get my program to write a blank line if the array segment
starts with a 0 or a 1. I have the if statment written down fine (i
believe), however the program skips the whole statement every time
through (found that out by stepping through the build). anyone know
what I'm doing wrong?
For s = 0 To UBound(Data) - 1
                    If Data(s).EndsWith(")") Then
                        l = Data(s).Length()
                        Data(s).Remove(0, l)
                    ElseIf Data(s).StartsWith("0") Then
                        fsStream.WriteLine()
                        fsStream.WriteLine(Data(s) + ", ")
                    ElseIf Data(s).StartsWith("1") Then
                        fsStream.WriteLine()
                        fsStream.WriteLine(Data(s) + ", ")
                    Else
                        fsStream.Write(Data(s) + ", ")
                    End If
                Next

The If statement must work, because the first part (If
Data(s).EndsWith(")") Then) works just fine

Author
4 Aug 2006 7:42 PM
Siva M
Remove() method doesn't remove the characters from the string (strings are
immutable, btw). Rather assign the return value from Remove() to another
string variable and use it for further comparison...

  ... ...
  x = Data(s).remove (0, I)
ElseIf (x.tartsWith("0") Then
.... ...

<monitor-radiat***@sbcglobal.net> wrote in message
news:1154718928.056797.179460@s13g2000cwa.googlegroups.com...
I'm trying to get my program to write a blank line if the array segment
starts with a 0 or a 1. I have the if statment written down fine (i
believe), however the program skips the whole statement every time
through (found that out by stepping through the build). anyone know
what I'm doing wrong?
For s = 0 To UBound(Data) - 1
                    If Data(s).EndsWith(")") Then
                        l = Data(s).Length()
                        Data(s).Remove(0, l)
                    ElseIf Data(s).StartsWith("0") Then
                        fsStream.WriteLine()
                        fsStream.WriteLine(Data(s) + ", ")
                    ElseIf Data(s).StartsWith("1") Then
                        fsStream.WriteLine()
                        fsStream.WriteLine(Data(s) + ", ")
                    Else
                        fsStream.Write(Data(s) + ", ")
                    End If
                Next

The If statement must work, because the first part (If
Data(s).EndsWith(")") Then) works just fine