|
-
Jun 4th, 2000, 06:44 PM
#1
Thread Starter
Junior Member
k i have to make a game 4 school
n i have saved a label to disk
now i want to get it back (4 a high scores thing)
so i did this
Open "a:MyFile.dat" For Input As #1
but i want to get it back so i can see it on tha screen!!!!
hhheeeellpppp meeee pplleaase!!!
-
Jun 4th, 2000, 08:21 PM
#2
Hyperactive Member
Heeeere is the helppp!
Try this with a textbox.
FileName = "a:\MyFile.dat"
F = FreeFile
Open FileName For Input As F
Text1.Text = Input$(LOF(F), F)
Close F
Good luck!
-
Jun 4th, 2000, 08:24 PM
#3
You have to use an Input # statement to read the data back into variables, which you can then assign to the labels' caption property. How is the data in "myfile.dat" stored?
"It's cold gin time again ..."
Check out my website here.
-
Jun 6th, 2000, 03:35 PM
#4
Thread Starter
Junior Member
lkjl
i saved it from VB??
"a:MyFile.dat" For Output As #1
-
Jun 6th, 2000, 04:03 PM
#5
Fanatic Member
Is it comma seperated, tab delimated, new line for each score? We need to know the format.
Iain, thats with an i by the way!
-
Jun 6th, 2000, 05:09 PM
#6
Thread Starter
Junior Member
ummm
i don't know
where does it show that?
-
Jun 6th, 2000, 05:16 PM
#7
Fanatic Member
open up the file in notepad and tell give us an example of what it looks like
Iain, thats with an i by the way!
-
Jun 6th, 2000, 05:29 PM
#8
Thread Starter
Junior Member
i copied and pasted what i had in that command button, then opened it in notepad, and this is what it had:
VERSION 5.00
Begin VB.Form Form4
Caption = "Form4"
ClientHeight = 3075
ClientLeft = 60
ClientTop = 465
ClientWidth = 4680
LinkTopic = "Form4"
ScaleHeight = 3075
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 615
Left = 2280
TabIndex = 0
Top = 1080
Width = 1215
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Open "a:MyFile.dat" For Input As #1
End Sub
I don't know if thats what u need though cuz it doesn't make ne sence 2 me 
-
Jun 6th, 2000, 05:32 PM
#9
Thread Starter
Junior Member
This is how i saved it:
Private Sub YesButton_Click()
Dim Data As String
Data = Form2.Label10.Caption
Open "a:MyFile.dat" For Append As #1
Print #1, Data
Close #1
MsgBox "Time Saved"
End Sub
-
Jun 6th, 2000, 05:32 PM
#10
Fanatic Member
Sorry, i meant your Dat file.
"myFile.Dat"
Iain, thats with an i by the way!
-
Jun 6th, 2000, 05:37 PM
#11
Thread Starter
Junior Member
yeh i just opened that, but all it had was what i had saved. I saved what a user of the game had entered.
-
Jun 6th, 2000, 05:43 PM
#12
Fanatic Member
Right
What exactly do you want to do with the data in this file. Please be specific.
And again, post an example of what the data in the file looks like.
e.g
Code:
100, 123, 99, 12
'or
100
123
99
12
'etc...
Iain, thats with an i by the way!
-
Jun 6th, 2000, 05:52 PM
#13
Thread Starter
Junior Member
k, the program i m making is a snakes and ladders boardgame. it has a timer, and at the end of the game, the user is asked to click when finished. When they click on that, a message box comes up, asking them for their name and then the time that they recieved, they type it in and it puts that data into label10. Then if they want to save thier game, they click a button, and the data that they typed in which is now in label10, saves to disk. i did this like this:
Dim Data As String
Data = Form2.Label10.Caption
Open "a:MyFile.dat" For Append As #1
Print #1, Data
Close #1
MsgBox "Time Saved"
now i want to be able to allow the user to bring back the score that they saved. so i created a button that would do this:
Open "a:MyFile.dat" For Input As #1
it opens the file, but i want to open it so it shows on the form.
at the moment what is in notepad, when dat is opened is exactly what the user typed in
eg.
amanda 1 min 13secs
-
Jun 6th, 2000, 06:00 PM
#14
Fanatic Member
Okaly dokly then.
Code:
'in button
'make sure the file exists
If dir$("myFile.dat") <> "" Then
'open yuor file.
Open "myFile.Dat" for Input As #1
'where data is your variable to hold info.
Line Input #1, data
'display the data in the label or to where ever
Label10.Caption = data
close #1
End If
Hope this helps.
Iain, thats with an i by the way!
-
Jun 6th, 2000, 06:09 PM
#15
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|