Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Prompt user using Windows form

Hi

I have a Windows Form that I use to prompt the user. It is loaded with a list that the user
has to make a selection from.
I have an OK button that then runs the rest of the code.
Is there a way to pause the code, show the form and then run the rest of the code
without havening to channel it through the OK button?

In essence, I want the Windows form to gather feedback just like the OpenFileDialog would in the
following code and gather feedback from the user
                      With Globals.ThisAddIn.oAUTOMATOR.OpenFileDialog1
                            .FileName = ""
                            .InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                            .Filter = Nothing
                            '.AddExtension
                            .ShowDialog()

                            sFileAndPath = .FileName
                            sPath = System.IO.Path.GetDirectoryName(sFileAndPath)
                            sFile = System.IO.Path.GetFileName(sFileAndPath)
                            oSource_File = sFileAndPath
                        End With
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

You need to replace .ShowDialog() with .Show() but ...

That will cause another problem: the line that follows check for .FileName which will be empty at best.

That means that you cannot have code after .Show that is dependant on the result of the dialog box.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks very much. That is exactly what I was looking for. The question was probably not that clear.