Vyndrox Posted January 8, 2004 Posted January 8, 2004 Try line1: filename = InputBox("Input a filename:", "File Lister", "my movies", 200, 300) filename = filename + ".txt" If System.IO.File.Exists(Application.StartupPath & "\" & filename) = True Then MsgBox("File exists", MsgBoxStyle.OKCancel, "File Lister") End If I want when the user push cancel he's goin back to 'line1:' But i don't know how you can check wich button the user has pushed :) Quote
Administrators PlausiblyDamp Posted January 8, 2004 Administrators Posted January 8, 2004 Personally I despise the InputBox function but you could do something like Dim fileName As String Do filename = InputBox("Input a filename:", "File Lister", "my movies", 200, 300) Loop Until fileName <> "" although I would use something more user-friendly like Dim sf As New SaveFileDialog sf.Title = "Input a filename" Dim fileName As String Do sf.InitialDirectory = Application.StartupPath sf.ShowDialog() fileName = sf.FileName Loop Until fileName <> "" Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Vyndrox Posted January 8, 2004 Author Posted January 8, 2004 wow, kewl man tnx. This is my first week programming in vb .net, i just have a little experience in delphi. Thats why my questions/solutions may look n00bish :P I already ordered the book visual basic .net for uni students, i get it in a few days :D Quote
Vyndrox Posted January 8, 2004 Author Posted January 8, 2004 Dim sf As New SaveFileDialog() sf.Title = "Input a filename" Dim fileName, i As String Do sf.InitialDirectory = Application.StartupPath sf.DefaultExt = "txt" sf.ShowDialog() fileName = sf.FileName Loop Until fileName <> "" I want that if u get the save file dialog, that save as type is 'as text' .txt and not empty i added 'sf.DefaultExt = "txt"' but that will only add the extension afterwards and i want that it's also visible that u can only save as .txt. Quote
*Experts* mutant Posted January 9, 2004 *Experts* Posted January 9, 2004 Look into the Filter property. It will let you spceify what files the dialog which display. If you want txt only you can do something like this: savedialog.Filter = "Text Files (*.txt)|*.txt" Frst you set the desciprtion you want to apear in the FileType dropdown on the dialog, and then the extension for the given description. Quote
Vyndrox Posted January 9, 2004 Author Posted January 9, 2004 yeah ur solution is exactley what i was lookin' for. TNX :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.