OpenFileDialog Shows Twice?

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

OpenFileDialog Shows Twice?
GoodGuy17
Hello,
I am using the following code from what I assume is correct.
Code: Select all
        OpenFileDialog1.ShowDialog()
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim Reader As New System.IO.StreamReader(OpenFileDialog1.FileName)
            TextBox1.Text = Reader.ReadToEnd
        End If
I have this problem: After you select a file and click open, it shows the dialog again. Then, you select it again and click open, and it works. Can somebody tell me why this happens? And how to fix it?
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: OpenFileDialog Shows Twice?
mandai
The reason for this is because ShowDialog is being called twice.
Get rid of the first line to solve this problem.
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: OpenFileDialog Shows Twice?
GoodGuy17
Thanks mandai!
3 posts Page 1 of 1
Return to “Tutorial Requests”