VB Advanced TEXT BOX problems

Thread Solved

Join Date: Nov 2007
Posts: 3
Reputation: jackfarrel is an unknown quantity at this point 
Solved Threads: 0
jackfarrel jackfarrel is offline Offline
Newbie Poster

VB Advanced TEXT BOX problems

 
0
  #1
Nov 24th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 14
Reputation: steve585 is an unknown quantity at this point 
Solved Threads: 1
steve585 steve585 is offline Offline
Newbie Poster

Re: VB Advanced TEXT BOX problems

 
0
  #2
Nov 25th, 2007
No problem man! Check this

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Open Text1.Text & ".txt" For Output As #1
  2. For n = 0 To 5
  3. Print #1, Text2.Text
  4. Next n
  5. Close #1
Last edited by steve585; Nov 25th, 2007 at 6:48 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3
Reputation: jackfarrel is an unknown quantity at this point 
Solved Threads: 0
jackfarrel jackfarrel is offline Offline
Newbie Poster

Re: VB Advanced TEXT BOX problems

 
0
  #3
Nov 25th, 2007
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC