Read Coordinates from a text file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Read Coordinates from a text file

Posts: 24Member
I need help writing something that will let VB recognise coordinates in a separate text file. I need it to read 9999,9999=#0000FF; and many of them in succession. The first 4 digits are pixels up, second 4 are pixels right, and #0000FF is a HTML color code. I need to get this done quickly so any help would be greatly appriciated.

• Posts: 617Member
: I need help writing something that will let VB recognise coordinates in a separate text file. I need it to read 9999,9999=#0000FF; and many of them in succession. The first 4 digits are pixels up, second 4 are pixels right, and #0000FF is a HTML color code. I need to get this done quickly so any help would be greatly appriciated.
:

Use something other then a comma to seperate the first 4 digits from the rest of your string (maybe a *) that way you can use the split function, say you have a string of coords like so:
9999*9999*#0000FF,...next coord,...next coord,...

you could use code like the following:

[code]
Dim strWholeValue, temp(), strUP, strRight, strColor as string

Open "c:coords.txt" for input as #1
While Not eof(1)
input #1, strWholeValue
temp = split(strWholeValue,"*")
strUp = temp(0)
strRight = temp(1)
strColor = temp(2)

Wend
close #1
[/code]

the split function works by assigning an array with the values it splits from the string you give it and the delimiter, in this case we give it a string containing "9999*9999*#0000FF" and a delimiter of "*" so it reads all of the char's until it finds the delimiter (*) then assigns it to the first position in the array (0), then it starts reading again after the (*) until it finds another (*) char and assigns it to the second position in the array (1), and it continues to do this until it runs out of chars.

Hope this helps.
[blue]
C:Dos
C:Dos Run
Run Dos Run
[/blue]