VB projects - Text File Viewer
Description: shows specified text file
Minimum requirements: VB5
Download: source code
Screenshot:

Project: Standard EXE
ActiveX Controls/Objects: comdlg32.ocx
Controls: dlg (CommonDialog), cmdFile (CommandButton), txtFile (TextBox), txtOutput (TextBox)
Code:
Option Explicit
Private Sub cmdFile_Click()
Dim sTemp As String
dlg.FileName = "*.txt"
dlg.ShowOpen
txtFile = dlg.FileName
If Dir(dlg.FileName) <> "" Then
If FileLen(dlg.FileName) > 32000 Then
MsgBox "File is bigger then 32 KB. Don't want to show it"
Else
Me.MousePointer = vbHourglass
txtOutput = ""
Open dlg.FileName For Input As 1
While Not EOF(1)
Line Input #1, sTemp
txtOutput = txtOutput & sTemp & vbCrLf
Wend
Close #1
Me.MousePointer = vbDefault
End If
Else
MsgBox "File not found", vbCritical, "Error"
End If
End Sub
Private Sub Form_Resize()
txtOutput.Height = Me.Height - 750
txtOutput.Width = Me.Width - 120
End Sub
|