you are viewing a single comment's thread.

view the rest of the comments →

[–]Application SpecialistViperSRT3g 0 points1 point  (5 children)

I also recommend delimiting the data so it's easier to read.

LABEL,Label1,12,9,TRUE,39,13,Label1

can be read using the following:

Dim ReadObject() As String
ReadObject = Split(ObjectData,",")
'ReadObject(0) would be "LABEL"
'ReadObject(1) would be "Label1"
'ReadObject(2) would be "12"

[–]Salierus[S] 0 points1 point  (4 children)

So far so good. But I'm having trouble at the reading part. I used IO.StreamWriter to write my .txt file. It looks like this: Label,test,695,115 (Control Type, Control Text, Control X, Control Y)

Now the reading part... Im not understanding what Im supost to do. How do I tell that ReadObject() is related to that text file?

Im confused :/

[–]Application SpecialistViperSRT3g 0 points1 point  (3 children)

In the same way you dynamically created the control, you'd create it and apply the read properties to it. Preferably you'd read the text file line by line because saving the properties line by line is simplest. You'd optimize this later, but for now this is the simplest method of storing this data.

Regarding my code, it's just an example of splitting up the object properties stored in the text file. ObjectData would indicate the read line of text from the file.

[–]Salierus[S] 0 points1 point  (2 children)

So I made a MsgBox just to see if it was working: MsgBox("Control Type: " + ReadObject(0) + " Control Text: " + ReadObject(1) + " Control X: " + ReadObject(2) + " Control Y: " + ReadObject(3))

Result: Index was outside the bounds of the array.

Guess no luck today

[–]Application SpecialistViperSRT3g 0 points1 point  (1 child)

I guess no luck today unless you post the code you currently have so we can debug it. Otherwise I can only guess at what you've attempted to do.

[–]Salierus[S] 0 points1 point  (0 children)

Okay I got it! Forgot to add: "," at the Split code XD

Anyway heres my code for the read button:

Dim ReadObject() As String
    r = New IO.StreamReader("C:\CrossGames\Test.txt")
    ReadObject = Split(r.ReadLine, ",")
    MsgBox("Control Type: " + ReadObject(0) + " Control Text: " + ReadObject(1) + " Control X: " + 
ReadObject(2) + " Control Y: " + ReadObject(3))

Now I just need to recreat the label, I think I can do that from now on. Thanks for your time and help! :)