[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

How do I integrate the VB6 CommonDialog control so that the user can enter their own file name and override a pre-determined file name?

I have a couple of VB6 subs that use a button click and fso to .Writeline some settings to a .txt type of file that can then use .Readline to restore the values.

Question: How do I integrate the CommonDialog control into this so that the user can enter their own file name and override the pre-determined file name? I just can't seem to get this to work...many thanks.

Private Sub mnu_SaveStatus_Click()
     SaveSettings App.Path & "\settings.set"
End Sub


Private Sub SaveSettings(ByVal FileName As String)

Set strm = fso.CreateTextFile(FileName, True)
     With strm

     .WriteLine Text1.Text
     .WriteLine Text2.Text
     .WriteLine Text3.Text

     .Close
     End With

End Sub
0
jazjef
Asked:
jazjef
1 Solution
 
GrahamSkanCommented:
You just use the control's FileName property.
Private Sub Command1_Click()
    Me.CommonDialog1.ShowOpen
    SaveSettings Me.CommonDialog1.FileName
End Sub

Open in new window

0
 
Deepu SreedharBI Software EngineerCommented:
Same like GrahamSkan said.
Place CommonDialogControl on your form and just call it on your Private Sub mnu_SaveStatus_Click()

 Like below:

Private Sub mnu_SaveStatus_Click()
    CommonDialogName.ShowOpen
    SaveSettings CommonDialogName.FileName
End Sub
   
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now