Link to home
Start Free TrialLog in
Avatar of hjaycox
hjaycox

asked on

name a file from user input

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

ASKER CERTIFIED SOLUTION
Avatar of mcix
mcix

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hjaycox
hjaycox

ASKER

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

Avatar of hjaycox

ASKER

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