Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Read Coordinates from a text file

mp3guymp3guy 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.

Comments

  • GideonOmegaGideonOmega 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)

    ...your code here
    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]

Sign In or Register to comment.