How to Save a List Using CommonDialog in VB6

  • Share
  • Print this article

The CommonDialog control in Visual Basic 6 lets you prompt the user for a location to save a file. The CommonDialog control takes care of all of the code to store the file and to interact with the computer's hard drive. You must create the code that opens the dialogue window, which also has the standard layout and buttons a Windows user is familiar with.

Instructions

    • 1

      Open the VB6 compiler program on your computer and open your desktop application to load all of the project files. Double-click the file you want to use to create the dialogue interface.

    • 2

      Drag and drop a CommonDialog control from the toolbox to the VB form. Type "cd" in the right "Properties" panel in the "Name" section. You use this name throughout your VB code.

    • 3

      Drag and drop a button control to the form. Use this button to open the control. Double-click the button to open the code that runs when the user clicks the button.

    • 4

      Type the following code to open the dialogue window:

      cd.InitialDirectory = "C:\myfiles"
      cd.ShowSave()

      The "myfiles" folder is set as the default, so the user is prompted to save the list in this folder. Change the folder to your preferred default folder. The user types a file name and clicks "Save," which saves the list to the hard drive.

Related Searches

References

Comments

Related Ads

Featured
View Mobile Site