Help with ListBox

1

I need you to help me with this part of my code in VB, in the ListBox I have to show an IP address to verify certain data that I have to show on screen when I run the program I always get a Warning of

  

ArgumentException occured Empty path name is not legal

I have been looking for that error for days and when I inspect the information I get a legend that says:

  

Argument not specific for parameter 'sender' of 'Privite Sub   Listbox1_Click (sender As Object, and As EventArgs) Handles ListBox1_Click

Annex part of my code so that they can verify in which part of the code I am wrong.

 Private Sub ListBox1_Click(sender As Object, e As EventArgs) Handles ListBox1.Click
    validar()
End Sub
 Public Sub validar()
    logfile = ListBox1.Text
    Dim file As New System.IO.StreamReader(logfile)
    Dim oneLine As String
    oneLine = file.ReadLine()
    RichTextBox2.Enabled = False
    While (oneLine <> "************ Report ***********")

        oneLine = file.ReadLine()
        If oneLine = "Final Status:         Passed" Then
            txtModelo.Clear()
            txtPO.Clear()
            txtDelivery.Clear()
            RichTextBox1.Clear()
            RichTextBox2.Clear()
            txtConsola.Clear()
            MessageBox.Show("El archivo seleccionado no contiene falla", "Part Replacement")
            Exit While
        ElseIf oneLine = "Final Status:         Aborted" Then
            RichTextBox2.Enabled = True
            MessageBox.Show("Este archivo contiene un abort, ingresa los comentarios de la falla", "Part Replacement")
        ElseIf oneLine = "************ Report ***********" Then
            logfile = ListBox1.Text
            leerdir()
            leerdel()
            leerfalla()
            leerpo()
            leermod()
            leerconsol()
            'materialType()
            SerealizadoFile()
            ImportarArchivo()
            MarketingPN()
        End If
    End While
End Sub

Event code Form1_Load :

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim thisDate As Date
    thisDate = Today
    txtFecha.Text = thisDate
    txtFechaCorta.Text = Format(thisDate, "yyyyMMdd")
    ListBox1.Items.Add(File)

    Dim currentTime As Date
    currentTime = TimeOfDay
    txtHora.Text = currentTime
    txtHoraDecimal.Text = Format(TimeOfDay, "hhmmss")

    If txtHoraDecimal.Text < 20000 Then
        txtTurno.Text = "1er"
    Else
        txtTurno.Text = "2do"
    End If
End Sub

They left me a comment that was deleted:

  

Jose Pilay: Where do you bring the File in? this line ListBox1.Items.Add(File) ?

    
asked by Elizabeth Flores Perez 09.06.2017 в 18:34
source

1 answer

0

Good Elizabeth,

The error that appears is an error issued by System.IO.StreamReader and comes to say that the name of the file that you are passing is empty.

You should check if the logfile has data or not before passing it as a parameter for the StreamReader:

If logfile <> String.Empty Then
    Dim file As New System.IO.StreamReader(logfile)
    //Código que sigue con el File
End If

I hope it helps you.

    
answered by 04.07.2017 в 15:38