3 Replies - 6607 Views - Last Post: 22 February 2011 - 01:45 AM Rate Topic: -----

#1 lokincni   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 17-January 11

HOW TO READ AND WRITE DATA FROM TXT FILE TO EXCEL FILE

Posted 17 February 2011 - 04:52 AM

Hi friend,

iam working on the data entry form,i can store the data in .txt
now i created a new command button called "showall" under this i have written a code to show the entire data to display in the picturebox,which is stored in my .txt database.and it is working for me fine,
now exactaly i want to display the same data in to new excel file when i click on the "showall" button.please guide me to do this and this is my coding done.

Private Sub showall_Click()
Form4.Show
Dim nom As String, yob As String, kit As String, dccode As String
Form4.pic1.Cls
Form4.pic1.Print "DATE", "ODAF NO", "KIT TYPE", "DC CODE"
Form4.pic1.Print "----", "-------", "--------", "-------"
Open "\\cniserver\cni\Lokesh\loki.txt" For Input As #1
Do While Not EOF(1)
Input #1, yob, nom, dccode, kit
Form4.pic1.Print nom, yob, kit, dccode
Loop
Close #1
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: HOW TO READ AND WRITE DATA FROM TXT FILE TO EXCEL FILE

#2 Jupiter 2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 05-June 09

Re: HOW TO READ AND WRITE DATA FROM TXT FILE TO EXCEL FILE

Posted 17 February 2011 - 02:54 PM

I think you are better to import the text data directly into Excel, from Excel itself.

You can use the (Excel) VB Editor to create a utility to do whatever you have done with VB6. It seems that you are using VB6 for the wrong reasons if the data is going to be inputted into Excel, anyway. However, if the VB6 utility (userform) is a standalone for users to imput the data then you save as a "Text File" from that form then you have something otherwise just creating the data directly into the text file then loading into a VB6 userform seems rather pointless.

Also, rather than using a picturebox to import the text data, you are better to use text boxes fields for each line of data to show your expertise in importing data or just import the whole lot into one big text box.
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes   User is offline

  • Product Manager
  • member icon

Reputation: 604
  • View blog
  • Posts: 3,085
  • Joined: 19-May 09

Re: HOW TO READ AND WRITE DATA FROM TXT FILE TO EXCEL FILE

Posted 18 February 2011 - 12:14 AM

Simplest way is to rename the file from .txt to .csv and just open it directly in Excel.
Was This Post Helpful? 0
  • +
  • -

#4 I'm High.   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-February 11

Re: HOW TO READ AND WRITE DATA FROM TXT FILE TO EXCEL FILE

Posted 22 February 2011 - 01:45 AM

Thanks bob very helpful for me at the moment.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1