Solved

name a file from user input

Posted on 1998-10-13
5
142 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 72
How does CurrentUser work? 10 38
checkbox to hide entire section 10 41
Collapse and expand table in Word 2010 2 32
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 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…

839 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