seleccione cada segunda línea de cadena vb.net

I have a text file it has lines of string, each line is separated by one empty line. like this:

1234

5678

I have a for loop running and its working fine:

For Each lognumber As String In RichTextBox1.Lines
    Dim log As String = RichTextBox1.Text
    log = Mid(lognumber, 1, 5) 'log number is line 1-5'
    MessageBox.Show(log)
Next

The only thing is that it shows me the empty line before the second line, how do I skip that empty line and just show the next string value. PS, I do not expect you to give me the answer in code, give me some sort of reference and I can take it from there. Unless you don't mind giving code.

preguntado el 12 de febrero de 14 a las 06:02

1 Respuestas

Just add a condition when showing the message box:

    For Each lognumber As String In RichTextBox1.Lines
        Dim log As String = RichTextBox1.Text
        log = Mid(lognumber, 1, 5) 'log number is line 1-5'
        If log.Length > 0 Then 
            MessageBox.Show(log)
        End If
    Next

Respondido 12 Feb 14, 06:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.