Reading text files

Reading text files

Anonymous
Not applicable
226 Views
2 Replies
Message 1 of 3

Reading text files

Anonymous
Not applicable
I would like to parse a text file when the data is separated by commas for
use in autocad blocks.
Anybody have an idea of how this can be done in visual basic?

Thank you,
Edward
0 Likes
227 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The most simple solution is to let the existing applications do the job.
Import the text file in Excel using the import functionality to separate the
text into Excel Cells.
Then use VBA to "read" the cells.

When you want to do the parsing your self then youre code would look like
1. Open the file
2. Read line
3. Look for ","
4. Look for text start (") in the first part, when uneven then repeat 3
5. use the MID() function to remove the first part from the line, repeat 3
6. repeat 2, when not EOF
7. Close file
0 Likes
Message 3 of 3

Anonymous
Not applicable
Add error trapping and some common sense. I scribbled this off the top of my
head so no telling if it'll work as written:

Dim fh As Integer, tmp As String
Dim tokens() As String, token

fh = FreeFile
Open for Input As fh
Do While Not EOF(fh)
Line Input fh,tmp
tokens = Split(tmp, ",")
For Each token In tokens
'
Next
Loop
Close fh

--
http://www.acadx.com
"That's no ordinary rabbit"


"Edward Bagby" wrote in message
news:BC75E7833547BE999797B72DECC79221@in.WebX.maYIadrTaRb...
> I would like to parse a text file when the data is separated by commas for
> use in autocad blocks.
> Anybody have an idea of how this can be done in visual basic?
>
> Thank you,
> Edward
>
>
>
0 Likes