Avatar of Murray Brown
Murray Brown
Flag 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
Visual Basic.NET

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
Éric Moreau

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
Mike Tomlinson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Thanks very much. That is exactly what I was looking for. The question was probably not that clear.
Your help has saved me hundreds of hours of internet surfing.
fblack61