?
Solved

Creating Output Text File with Unique Name

Posted on 2002-04-05
3
Medium Priority
?
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

801 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