I am useing the OpenFileDialog component with a Button Sub to use the text file that the user selects (it can change everyday) in the next part of my program that will read that file and then covert it into an xml format. How do I get the second part of my program to use the file selected?

Private Sub Button1_Click(ByVal sender As System.Object, _
   ByVal e As System.EventArgs) Handles Button1.Click
   If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
     Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
     MessageBox.Show(sr.ReadToEnd)
     sr.Close()
   End If
End Sub

thanks.

use the FileOK event of the openfiledialog.

I am useing the OpenFileDialog component with a Button Sub to use the text file that the user selects (it can change everyday) in the next part of my program that will read that file and then covert it into an xml format. How do I get the second part of my program to use the file selected?

Private Sub Button1_Click(ByVal sender As System.Object, _
   ByVal e As System.EventArgs) Handles Button1.Click
   If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
     Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName)
     MessageBox.Show(sr.ReadToEnd)
     sr.Close()
   End If
End Sub

thanks.

Thanks for the help. This solved my problem

could you post your complete code to use FileOK... sorry... im newbie in vb.net

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.