I've searched for this but I can't find it:

I have a listbox with numbers and I just want to save them when the user clicks Save_Click() as a SAVE AS function. I've used this, but I get errors:

VB Code:
  1. Private Sub Command2_Click()
  2.  
  3. With CommonDialog1  'open a with statement as there is a lot of code
  4.      .DialogTitle = "Save"  'sets the dialog title
  5.      .InitDir = "C:\"  'sets the initial directory
  6.      .Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"  'sets the file
  7.      'types
  8.  
  9.      .ShowSave  'show the dialog
  10. End With
  11.  
  12. List2.SaveAs CommonDialog1.FileName  'save to the specified file
  13.  
  14. End Sub