I’m by no means an experienced programmer. This task I have is very likely a one-off, so don’t feel bad for giving me answers instead of pointing me in the right direction 😛
I’ve searched as long as I can bear, and just can’t find what I’m after.
I just need to be able to move to the next substring of a string.
In this instance, “go to next substring” equates to “go to next line”.
I just need to be told that one command and I’ll be on my way, but I can’t find any trace of it.
Here’s a snippet of code with the magic command installed:
Dim count As Integer
Dim line As String
Dim lines As String() = My.Computer.FileSystem.ReadAllText("C:\test.txt").Split(New Char() {vbCrLf})
For Each line In Lines
If line.Contains("#")
count = 0
**GO TO NEXT LINE**
Do Until line.Contains("#")
count = count + 1
**GO TO NEXT LINE**
Loop
Console.WriteLine(line & ", " & count)
End If
Next
Unless I’m missing something, I should be able to use text formatted like this:
#VERSE1
Lyrics lyrics
Lyrics lyrics
#CHORUS1
Lyrics lyrics
Lyrics lyrics
Lyrics lyrics
Lyrics lyrics
#VERSE2
Lyrics lyrics
Lyrics lyrics
Lyrics lyrics
#CHORUS2
Lyrics lyrics
Lyrics lyrics
Lyrics lyrics
Lyrics lyrics
Lyrics lyrics
#END
And receive the result:
#VERSE1, 2
#CHORUS1, 4
#VERSE2, 3
#CHORUS2, 5
#END, 0
I apologize if I am wildly off the mark. I’m just putting together bits and pieces I’ve found from various tutorials.
I’ve managed to get all the other functions I need working with Googling alone, but this last task has me stuck.
Thanks!
I think you need to do something like this. What you are trying to do is move your index in two directions. You need to iterate over the substrings till you see a
#the problem being once you get there yourForstatement will move it past that record. I have created an example using your file that seems to work using a basicForstatement. See if it works for you.It’s output looks like: