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?
Printable View
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?
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
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
Good luck!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
Thank you... it's sort of the same as QB. Only Qbasic doesn't work with objects and stuff.
Code is all messed up Jop.Quote:
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
All fixed up for ya :rolleyes:.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