Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

how to read data from Form to txt/doc file

Question posted by: Anila (Newbie) on July 24th, 2008 10:27 AM
Hi all,

I created Form for the employee data entry, and the fields are like EmpName, date of birth, address, gender, education qualification, and also command buttons like clear, submit and close.

I am trying to do is when we enter data into the FORM and press Submit button those data will send to some text file like Employee.txt.

I am not getting that. please help me its urgent.


Private Sub cmdSubmit_click()
Dim intFileNo As Integer
intFileNo = FreeFile
Open "E:\VB\Employee.txt" For Input As #1

Do While Not EOF(1)
Input #1, strName, intDay,intMonth,intYear,strAddress,StrEducation
Print #1, strName; intDay; intMonth; intYear; strAddress; StrEducation
EOF (1)
Loop
Close #1
end sub

This is my code. its not showing any error but its not printing the data into the text file. for this i am not using any database. just simply need to appear in txt file.
please help me.
TTCEric's Avatar
TTCEric
Newbie
26 Posts
July 24th, 2008
12:50 PM
#2

Re: how to read data from Form to txt/doc file
Quote:

Dim intFileNo As Integer
intFileNo = FreeFile
Open "E:\VB\Employee.txt" For Input As #1


You are not using intFileNo. You need to use it instead of using '1'.

In code:

Open "file.txt" For Input As #intFileNo

I dont know why you are not getting invalid file handle for 1, though.

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,798 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Visual Basic Forum Contributors