Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: VB6 Text files  (Read 7582 times)

0 Members and 1 Guest are viewing this topic.

Bob Wilkin

  • Guest
VB6 Text files
« on: July 28, 2004, 03:03:36 PM »
I need to write a vb script that will extract a string from a text file. The only problem is that I'm having trouble loading the text file. I can get the string easily enough with len() and mid() statements, but how the *censored* do you load or open a text file inside runtime?

Joleen

  • Guest
Re: VB6 Text files
« Reply #1 on: July 29, 2004, 05:14:04 AM »
Use the Open dialog control.

mims1979

  • Guest
Re: VB6 Text files
« Reply #2 on: September 14, 2004, 02:30:21 PM »
you need to use the open command.

Here are a couple examples:

open file, read 1st line into variable "data"
Code: [Select]

Open (App.Path & "\filename.txt") For Input As #1
Line Input #1, Data
Close #1
msgbox data


Open file, run through the file doing something to each line:
Code: [Select]

Open (App.Path & "\filename.txt") For Input As #2
Do Until EOF(2)
 Line Input #2, grpfor
 msgbox grpfor
Loop
Close #2