Solved

how to make a default file name in a save file dialog for users

Posted on 2004-04-02
7
1,262 Views
Last Modified: 2013-12-25
hi everybody...I wanna know how to make a default file name in a save file dialog for users
and I want to open a text file in VB ...how can I do that....?

Thanks


0
Comment
Question by:starstarhk
  • 2
  • 2
7 Comments
 
LVL 27

Accepted Solution

by:
jjafferr earned 25 total points
ID: 10746115
Hi starstarhk,
This is the second part of your question:

           Open "C:\DeleteMe.txt" For Input As #1    ' Open file for input.
            Do While Not EOF(1)    ' Loop until end of file.

            Line Input #1, TextLine    ' Read line into variable.
' do something here
           Loop
           Close #1            'Close the input file and move to the next file


Hope this helps

jaffer
0
 

Author Comment

by:starstarhk
ID: 10746139
but I am using FileSystemObject, the object name is SaveDialog..

SaveDialog.CancelError = True
    On Error GoTo ErrHandler
       SaveDialog.DialogTitle = "Save your File!"
    SaveDialog.Filter = "Text File(*.txt)|*.txt|"
    SaveDialog.ShowSave
    fileName = SaveDialog.fileName
       If Not FSO.FileExists(fileName) Then ' if not exist→Create
       Set TS = FSO.CreateTextFile(fileName)
    Else  ' if exist→Open
       Set TS = FSO.CreateTextFile(fileName, ForWriting)
   End If



And how to open a text file...is it ShellExecuteEX(....,.....)?
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 10746272
I don't know about FileSystemObject and SaveDialog, I have a different way to do it, its through a module. If you wish, I can provided to you.

Now for your second part,
Do you want to open a txt file and read its content from VB,
(I already gave you the answer for this option)
OR
Open a txt file in notepade?
Dim myProcess as New Process()
myProcess.StartInfo.FileName = "Notepad.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
myProcess.Start()

jaffer
0
 
LVL 5

Assisted Solution

by:crazycomputers
crazycomputers earned 25 total points
ID: 10746527
According to MSDN:

"In the CommonDialog control, you can set the FileName property before opening a dialog box to set an initial filename."

SaveDialog.FileName = "default file.txt"   ' for example
0
 
LVL 5

Expert Comment

by:crazycomputers
ID: 11044249
Agreed.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 57
Windows 10 start screen issues 9 55
VB6 - Compare and highlight cell not the same 3 52
How to measure sizes and angles in scanned images ? 3 65
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question