?
Solved

name a file from user input

Posted on 1998-10-13
5
Medium Priority
?
147 Views
Last Modified: 2010-04-30
in vb4 16 bit win 3.1

user types in data (8 digits long) into text1
eg text1 = cake
Using this user data (cake)  what is the code for greating this file (eg cake.dat)  , open it for output , write to it and close it.

I have tried astring = val(form1.text1.text)
                  open "c:\xxe\astring.dat" for output as #1
                       write #1: close #1
when I go to view that file it has been saved as Astring.dat
I need it saved as cake.dat
Help   ........I am SHUT OFF until I can do it!!!!!!!!
 

0
Comment
Question by:hjaycox
[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
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
mcix earned 200 total points
ID: 1439786
Dim mstrFileName As String
Dim mlngFileHandle As Long
mstrFileName = "C:\xxe\" & Text1.Text & ".dat"
mlngFileHandle = FreeFile

Open mstrFileName For Output As #mlngFileHandle
Write #mlngFileHandle, "SOME TEST"

Close #mlngFileHandle


0
 

Author Comment

by:hjaycox
ID: 1439787
You saved me. Thanks.......
Want 50 more points??????
answer this one.

After the "c:\xxe\" & text1.text & ".dat" has been put into the directory ,  How do I call a window that will list ALL of the .dat
files in the xxe directory.
then select one of these files and load it BACK into the original program so it can be read or modified?????
0
 
LVL 4

Expert Comment

by:mcix
ID: 1439788
There are a couple of ways to do that...

Explain a little more about what you want to do...

Here is some generic code to fill a list box:

Function ListFiles(vstrPath As String, vstrSpec As String, lstControl As ListBox)

Dim mstrCurrentFile As String

mstrCurrentFile = Dir(vstrPath & vstrSpec)
Do While mstrCurrentFile <> ""
    lstControl.AddItem vstrPath & mstrCurrentFile
    mstrCurrentFile = Dir
Loop

End Function


Private Sub Form_Load()
    ListFiles "C:\xxe\", "*.dat", List1
End Sub

0
 

Author Comment

by:hjaycox
ID: 1439789
This is a recipe program for the wife. She wants it simple, 3 text boxes. 1 is the name (8 bites) the second is the ingredient (800) and the last is the directions (1200). After she fills out the form she saves it by the name.dat ((((THANK YOU)))). A week later she wants to pull it up and make dinner. SO she starts the program...hits the view button.....selects the file..... loads it, reads it, maybe changes it. then if changed,  resaves it., else quits the program.

So , what do I do??? I need a window that will show all the dat files. Choose one by its name....load it to the original program etc.
0
 
LVL 4

Expert Comment

by:mcix
ID: 1439790
hjaycox,

Start a new question on that in the Visual Basic Controls Section...

I am sure either I will have a solution for you or someone can help.

Mark
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

762 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