Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27469

VB 2010 Express - File / Web Manipulation Struggles

$
0
0
Okay i have a small program that when you click the button you browse for a file, the file contains a set of URLs all seperated by comma's. when i run the program by just printing the URL's to a message box, it prints them one by one, closing the last one before it.

Ive implemented this so that when i open the text file, it will pick up the URL and open and webpage. but what my problem is that it just goes to the last URL in the text file, not through the list.

any help please?

Code:

Public Class Form1

    Private Sub BrowseBtn_Click(sender As System.Object, e As System.EventArgs) Handles BrowseBtn.Click

        OpenFileDialog.ShowDialog()

        LabelFile.Text = OpenFileDialog.FileName

        Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(LabelFile.Text)

            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")

    Dim currentRow As String()
            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
    Dim currentField As String
                    For Each currentField In currentRow
                        WebBrowser.Navigate(currentField)
                        LabelURL.Text = currentField
                    Next
                Catch ex As Microsoft.VisualBasic.
                            FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message &
                    "is not valid and will be skipped.")
                End Try

            End While

        End Using

    End Sub

End Class


Viewing all articles
Browse latest Browse all 27469

Trending Articles