get line of file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gurk

    #1

    get line of file

    hallow al

    in my program you can save and open files, he save file is OK
    if the user clickes save, it saves the titel of the project he created(and
    lots more in the future).

    the titel is at the first line of the saved file.

    but how can i open thet file, so it gets the first line, and places the text
    on the caption of the form.

    for example he opens a file named my project, in the file the first line is
    worksheet.

    so a form has to open with caption worksheet

    the opening of the file is no problem, i'm using a common dialog so the user
    can choose of saved projects.

    thank you all

    Maarten


  • Rick Rothstein

    #2
    Re: get line of file

    > in my program you can save and open files, he save file is OK[color=blue]
    > if the user clickes save, it saves the titel of the project he[/color]
    created(and[color=blue]
    > lots more in the future).
    >
    > the titel is at the first line of the saved file.
    >
    > but how can i open thet file, so it gets the first line, and places[/color]
    the text[color=blue]
    > on the caption of the form.
    >
    > for example he opens a file named my project, in the file the first[/color]
    line is[color=blue]
    > worksheet.
    >
    > so a form has to open with caption worksheet
    >
    > the opening of the file is no problem, i'm using a common dialog so[/color]
    the user[color=blue]
    > can choose of saved projects.[/color]

    The CommonDialogBox does not "open" the file selected by your user; it
    simply returns the path and filename of the user's selection. You need
    to use the Open statement to "open" the file.

    FF = FreeFile
    Open CommonDialog1.F ileName For Input As #FF

    Then read in the first line using the Line Input statement

    Line Input #FF, SomeVariableToS toreFileNameIn

    If you need other lines from the file, you can continue using the Line
    Input statement to read them. When finished, remember to close the file.

    Close #FF

    Rick - MVP

    Comment

    • Raoul Watson

      #3
      Re: get line of file


      "Gurk" <gurkjaan@hotma il.com> wrote in message
      news:4148225d$0 $4131$ba620e4c@ news.skynet.be. ..[color=blue]
      > hallow al
      >
      > in my program you can save and open files, he save file is OK
      > if the user clickes save, it saves the titel of the project he[/color]
      created(and[color=blue]
      > lots more in the future).
      >
      > the titel is at the first line of the saved file.
      >
      > but how can i open thet file, so it gets the first line, and places the[/color]
      text[color=blue]
      > on the caption of the form.
      >
      > for example he opens a file named my project, in the file the first line[/color]
      is[color=blue]
      > worksheet.
      >
      > so a form has to open with caption worksheet
      >
      > the opening of the file is no problem, i'm using a common dialog so the[/color]
      user[color=blue]
      > can choose of saved projects.
      >
      > thank you all
      >
      > Maarten
      >[/color]

      And after what Rick said, you can do:

      ' if you need to display different forms
      If lineread = "Journal" then Journal.Show
      If lineread = "Games" then Games.Show
      ..
      ....e t c

      If you have a generic form and just need to change the title:

      myForm.Caption = lineread
      myForm.Show


      Comment

      Working...