•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 455,969 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,760 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1885 | Replies: 2 | Solved
![]() |
•
•
Join Date: Nov 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I am using Visual basic 6
I am trying to create a new txt file with the textbox (text1) contents.
But instead of calling that text file "Stored.txt" as I currently am doing, I am trying to create the new .txt file with the text from the textbox.
Private Sub Command1_Click()
Dim F As Integer 'Setup up constant file number
F = FreeFile ' Set F to the next free file number
'open file Text.txt
Open ("C:\PROGRA~1\ASTKA\SADM\info\Stored.txt) For Append As F
'write text to file
Print #F,
Print #F, "First Name:", Text1.Text
Print #F, "Last Name:", Text2.Text ' Normaly this info will get stored in the registery!
Print #F,
Print #F,
'Close file
Close #F
End Sub
So basically, if someone enters their "First Name" in the textbox (text1) it will not only write it to a file in: C:\PROGRA~1\ASTKA\SADM\info\ but it will name it based on the contents of "text1" so if someone enters "bob" that new text file will be called "bob.txt" and it will contain "firstname: bob" (at the same time) I do not want a static name "Stored" for every persons name, I want the file to change and create new ones for everyones name, and the files will be named each persons name.
Any help?? I've searched and searched and found nothing.
I am trying to create a new txt file with the textbox (text1) contents.
But instead of calling that text file "Stored.txt" as I currently am doing, I am trying to create the new .txt file with the text from the textbox.
Private Sub Command1_Click()
Dim F As Integer 'Setup up constant file number
F = FreeFile ' Set F to the next free file number
'open file Text.txt
Open ("C:\PROGRA~1\ASTKA\SADM\info\Stored.txt) For Append As F
'write text to file
Print #F,
Print #F, "First Name:", Text1.Text
Print #F, "Last Name:", Text2.Text ' Normaly this info will get stored in the registery!
Print #F,
Print #F,
'Close file
Close #F
End Sub
So basically, if someone enters their "First Name" in the textbox (text1) it will not only write it to a file in: C:\PROGRA~1\ASTKA\SADM\info\ but it will name it based on the contents of "text1" so if someone enters "bob" that new text file will be called "bob.txt" and it will contain "firstname: bob" (at the same time) I do not want a static name "Stored" for every persons name, I want the file to change and create new ones for everyones name, and the files will be named each persons name.
Any help?? I've searched and searched and found nothing.
•
•
Join Date: Nov 2007
Posts: 14
Reputation:
Rep Power: 2
Solved Threads: 1
No problem man! Check this
Open Text1.Text & ".txt" For Output As #1
For n = 0 To 5
Print #1, Text2.Text
Next n
Close #1 Last edited by steve585 : Nov 25th, 2007 at 6:48 am.
•
•
Join Date: Nov 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I found the solution:
Private Sub Command1_Click()
Text2.Text = Date
Dim F As Integer 'Setup up constant file number
Dim filepathname As String
F = FreeFile ' Set F to the next free file number
'open file Text.txt
filepathname = "C:\PROGRA~1\ASTKA\SADM\info\" & Text1.Text & ".Doc"
Open (filepathname) For Append As F
Print #F,
Print #F, "Full Name:", Text1.Text
Print #F, "Date of attendance:", Text2.Text ' Normaly this info will get stored in the registery!
Print #F,
Print #F,
'Close file
Close #F
End Sub
Private Sub Command1_Click()
Text2.Text = Date
Dim F As Integer 'Setup up constant file number
Dim filepathname As String
F = FreeFile ' Set F to the next free file number
'open file Text.txt
filepathname = "C:\PROGRA~1\ASTKA\SADM\info\" & Text1.Text & ".Doc"
Open (filepathname) For Append As F
Print #F,
Print #F, "Full Name:", Text1.Text
Print #F, "Date of attendance:", Text2.Text ' Normaly this info will get stored in the registery!
Print #F,
Print #F,
'Close file
Close #F
End Sub
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- writing from bottom up in rich text box (VB.NET)
- pass the value to the text box (JavaScript / DHTML / AJAX)
- a default value in a text box (Visual Basic 4 / 5 / 6)
- Text Box Newbie help (Visual Basic 4 / 5 / 6)
- Text box question (C#)
- Text box population from DBgrid. HELP!! (Visual Basic 4 / 5 / 6)
- text is being written in text box (Web Browsers)
- Help with text box height (HTML and CSS)
- Cannot enter any text in a IE text-box (Viruses, Spyware and other Nasties)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB6 / Access DAO Add Field to Existing Table/Query
- Next Thread: Connecting V.B 6.0 with ms-excel 2003


Linear Mode