Results 1 to 15 of 15

Thread: hhheeeelllpppp me please!!!!!!!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21

    Exclamation

    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!!!

  2. #2
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Thumbs up 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!

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21

    lkjl

    i saved it from VB??
    "a:MyFile.dat" For Output As #1

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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!

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21
    ummm
    i don't know
    where does it show that?

  7. #7
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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!

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21
    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

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21
    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

  10. #10
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Sorry, i meant your Dat file.

    "myFile.Dat"
    Iain, thats with an i by the way!

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21
    yeh i just opened that, but all it had was what i had saved. I saved what a user of the game had entered.

  12. #12
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    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!

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21
    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

  14. #14
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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!

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    21

    Talking

    Thank you!!!!!!!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width