Saving multiple things

lucasmeloch
04-17-2003, 01:48 PM
Ok guys I need some help from you kind people. I would like someone to give me an example of saving two labels (label1 & label2) to a single file that when re-opened will go back to the original labels. I dont really mind what format the save file is in.


Thanks

-Lucas

Iceplug
04-17-2003, 02:03 PM
Open file For Input As #1
Print #1, X
Print #2, X
Close #1
Look up these functions /statements in MSDN.
You assign the captions to a variable and then write the variable to file. :)

loquin
04-17-2003, 02:48 PM
errrh... maybe open file for output... :o

lucasmeloch
04-19-2003, 06:02 PM
Iceplug, thanks that helped a little but i could really do with an example. I would like someone to give me an example of saving captions of "label1" and "label2" to "C:\test.txt" and then re-opening them from teh same directory into their original boxes.

Thanks Again

Lucas

SnakeChomp
04-19-2003, 06:13 PM
We cannot write code for you. You need to try something on your own and come back to us with your code if you have any problems. ;)

dragnut
04-19-2003, 07:48 PM
What Iceplug gave you is about as close to being the sample you want as you can get.
Look up these functions/statements...
open
close
input
line input
output
append
print #

Thats more than enough to get you started.
Oh, helpful hint...the x's in Iceplugs sample would be your labels

Shawn

Robse
04-19-2003, 08:03 PM
errrh... maybe open file for output... :o

and also errrh... maybe better

Open file For Output As #1
Print #1, X1
Print #1, X2
Close #1

:o

lucasmeloch
04-20-2003, 09:32 AM
Ok thanks for the help. I have now got it working I use the code:

Private Sub cmdsave_Click()
Dim hFile As Long
Dim sFilename As String

sFilename = "c:\windows\desktop\test.txt"
hFile = FreeFile
Open sFilename For Output As #hFile
Print #hFile, Label1.Caption
Print #1, Label2.Caption
Close #hFile
End Sub

But now I have problems re-opening the file into their original places. My attempt is:

Private Sub cmdopen_Click()

Dim lngAvailableFile As Long
Dim sFilename As String


sFilename = "c:\windows\desktop\test.txt"
lngAvailableFile = FreeFile
Open sFilename For Input As lngAvailableFile
Label1.Caption = Input$(LOF(lngAvailableFile), lngAvailableFile)
Close lngAvailableFile

End Sub

The problem is that this is only opening the whole file into the one label. I have tried several other ways to get it working but I cannot do it. A little help please

Thanks

Lucas

bibiteinfo
04-20-2003, 09:42 AM
Ok what you could do is to use the split() function and when you put the code into the file, you add this mark : /|\ or whatever you like then when you come back, you all load it into an array and the you split it so exemple for label1 you will have string(0) and for label 2 string(1)

Hope it help :)


P.S : String() = Split(sFilename, "/|\")

lucasmeloch
04-20-2003, 10:24 AM
thanks that heled me finish my app. Thank you very much!!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum