Writing a blank line under an if statement

  • Thread starter Thread starter monitor-radiation
  • Start date Start date
M

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
 
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
.... ...

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
 
Back
Top