Solved

name a file from user input

Posted on 1998-10-13
5
139 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
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
mcix earned 50 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now