How to Use Openfiledialog in Visual Basic Express

Visual Basic provides a set of windows controls to perform common user required functionality. One of the components is the OpenFileDialog control. This control is used to select a file to open from the computer executing the application.

Things You'll Need

  • Visual Basic Express Edition
Show More

Instructions

    • 1

      Open Visual Basic Express Edition and create a new project using the"Windows Forms Template."

    • 2

      Select "Ctrl" + "Alt" + "x" to open the toolbox menu. Drag the OpenFileDialog icon from the toolbox menu onto the form. Label the OpenFileDialog component as "OpenFileDialog1."

    • 3

      Drag a button icon onto the form from the toolbox menu and label it "Button1."

    • 4

      Double click the button labeled "Button1" and place the following code in the subroutine:
      OpenFileDialog1.ShowDialog()

    • 5

      Press the "F5" key to execute the application in debug mode. Click "Button1" and the OpenFileDialog box will be displayed. Select a file using the dialog box and press "Open" button. The OpenFileDialog box will then close.

Tips & Warnings

  • Add additional code to handle the value of the file returned from the OpenFileDialog component.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured