?
Solved

Creating Output Text File with Unique Name

Posted on 2002-04-05
3
Medium Priority
?
168 Views
Last Modified: 2010-05-02
Hello,

I need very simple explanations. I am experimenting with VB and can get easily confused.

I am creating a simple app that creates a text file for me. I am trying to figure out how to get my app to create a filename via my input rather than hard coding the filename. I tried to use the following but it just prints everything between the quotes. Do you have a suggestion on how to do this? As you will see, the OPEN command is erroneous. I would like to put the value in a text box and then have that be the filename.

Private Sub Command1_Click()
    Dim IntFile As Integer
    IntFile = FreeFile
    Open "C:\Batch\Dat\(Text1.Text).DAT" For Append As #IntFile
        Print #IntFile, "ConvertType=" & CStr(Combo1.Text)
        Print #IntFile, "ConvertFrom=" & CStr(Combo2.Text)
        Print #IntFile, "ConvertTo=" & CStr(Combo3.Text)
        Print #IntFile, "FromDatabase=" & CStr(Text2.Text)
        Print #IntFile, "FromUserID=" & CStr(Text3.Text)
        Print #IntFile, "FromPassword=" & CStr(Text4.Text)
        Print #IntFile, "FromChecked=" & CStr(Text5.Text)
        Print #IntFile, "ToDatabase=" & CStr(Text6.Text)
        Print #IntFile, "SearchValue=" & CStr(Text7.Text)
        Print #IntFile, "Convert=" & CStr(Combo4.Text)
        Print #IntFile, "Start"
    Close #IntFile
End Sub

Eventually, I want to add browsing capability that will ask for the source file. The FromDatabase would be the default property for the ToDatabase and for the Text filename. For instance, if my FromDatabase filename is ABC.NSF the Output filename would be ABC.PST and the text file would be named ABC.DAT.

Thank you in advance,

John
0
Comment
Question by:jhieb
3 Comments
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 220 total points
ID: 6921912
YOu need to remove the reference to Text1.Text from within the quotes, e.g.:

Open "C:\Batch\Dat\(Text1.Text).DAT" For Append As #IntFile

Becomes

Open "C:\Batch\Dat\" & Text1.Text & ".DAT" For Append As #IntFile
0
 
LVL 1

Author Comment

by:jhieb
ID: 6921916
I was just getting ready to add a PS. Also, if the file exists how to I tell it to overwrite it?
0
 
LVL 20

Expert Comment

by:hes
ID: 6921928
as bhess said
Open "C:\Batch\Dat\" & Text1.Text & ".DAT" For Append As #IntFile
to overrite change to
Open "C:\Batch\Dat\" & Text1.Text & ".DAT" For Output As #IntFile
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

831 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