I have a legacy code using CDSave.diaglog, CDSave.title, CDSave.filename. How to convert to VB2008?
Thanks,
Printable View
I have a legacy code using CDSave.diaglog, CDSave.title, CDSave.filename. How to convert to VB2008?
Thanks,
We need a lot more information... What is that "CDSave" thing? Is it a form? What does CDSave.diaglog, CDSave.title and CDSave.filename do?
The legacy code tried to open and save text into a file -
CDSave.Title = "Select Log File to Save As"
CDSave.ShowDialog()
On Error GoTo badfile
FileOpen(2, CDSave.FileName, OpenMode.Output)
...
But Vb2008.NET doesn't recognize CDSave. How to convert to the above into VB.net or change something to make the legacy code work?
Thanks,
My guess is it is a CommonDialogControl from VB6 which encompased the "save" "open" type dialogs. You would use a SaveFileDialog control which you can find in the toolbox under the "dialogs" section. It works nearly the same way as VB6.
Use the SaveFileDialog class as Kleinma suggested. Something like this:
Code:Using sfd As New SaveFileDialog()
With sfd
.Title = "Select Log File to Save As"
.Filter = "Text File (*.txt)|*.txt"
.OverwritePrompt = True
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
System.IO.File.WriteAllText(.FileName, "the text to write to the file here")
End If
End With
End Using