Results 1 to 7 of 7

Thread: [RESOLVED] How to convert CDSAVE. in VB6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Resolved [RESOLVED] How to convert CDSAVE. in VB6

    I have a legacy code using CDSave.diaglog, CDSave.title, CDSave.filename. How to convert to VB2008?

    Thanks,

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: How to convert CDSAVE. in VB6

    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?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Re: How to convert CDSAVE. in VB6

    Quote Originally Posted by stanav View Post
    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,

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: How to convert CDSAVE. in VB6

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Re: How to convert CDSAVE. in VB6

    Quote Originally Posted by kleinma View Post
    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.
    you points out the key point. Thank you very much.

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [RESOLVED] How to convert CDSAVE. in 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
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    135

    Re: [RESOLVED] How to convert CDSAVE. in VB6

    Quote Originally Posted by stanav View Post
    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
    I appreicate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width