Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 :)

  • Administrators
Posted

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 <> ""

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Posted

           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.

  • *Experts*
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...