Results 1 to 5 of 5

Thread: Viewing a file

  1. #1

    Thread Starter
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    Unhappy

    Can anybody tell this newbie how to view the contents of a file; how to view the contents of the autoexec.bat in a scrolling textbox? Please?

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Add this to your form, add a textbox with the scrollbar property to 2. Both

    Code:
    Private Sub Form_Load()
    Dim tmp$, fn%
    fn = FreeFile
    Open "c:\autoexec.bat" For Input As #fn
    Input #fn, tmp
    Close #fn
    Text1 = tmp
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    OK follow these steps.[*]Put a textbox on a form and set the MultiLine property to True[*]Optionally you can set the ScrollBars property[*]In code get a free file number by calling FreeFile[*]Open the file for Input[*]Read the contents and assign it to the TextBox[*]Close the file
    Code:
    Private Sub Command1_Click()
        Dim iFile As Integer
    
        iFile = FreeFile
        Open "C:\AutoExec.Bat" For Input As #iFile
        Text1 = Input(LOF(iFile), iFile)
        Close #iFile
    End Sub
    Good luck!

  4. #4

    Thread Starter
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    Thanx

    Thank you... it's sort of the same as QB. Only Qbasic doesn't work with objects and stuff.

  5. #5
    Guest
    Originally posted by Jop
    Add this to your form, add a textbox with the scrollbar property to 2. Both

    Code:
    Private Sub Form_Load()
    Dim tmp$, fn%
    fn = FreeFile
    Open "c:\autoexec.bat" For Input As #fn
    Input #fn, tmp
    Close #fn
    Text1 = tmp
    End Sub
    Code is all messed up Jop.

    Code:
    Private Sub Command1_Click()
    
        Dim strLine$
        Open "c:\autoexec.bat" For Input As #1
        Do While Not EOF(1)
        Line Input #1, strLine$
        Text1.Text = Text1.Text & strLine$ & vbCrLf
        Loop
        Close #1
        
    End Sub
    All fixed up for ya .

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