home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form TStreamForm
- Caption = "TextStream Object Demo"
- ClientHeight = 5775
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 9045
- LinkTopic = "Form1"
- ScaleHeight = 5775
- ScaleWidth = 9045
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton bttnReadFile
- Caption = "Read File"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 7320
- TabIndex = 2
- Top = 5160
- Width = 1575
- End
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 4815
- Left = 120
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 1
- Text = "TStream.frx":0000
- Top = 120
- Width = 8775
- End
- Begin VB.CommandButton bttnCreateFile
- Caption = "Create File"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 5640
- TabIndex = 0
- Top = 5160
- Width = 1575
- End
- Attribute VB_Name = "TStreamForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Dim FSys As New FileSystemObject
- Private Sub bttnCreateFile_Click()
- Dim OutStream As TextStream
- TestFile = App.Path & "\textfile.txt"
- Set OutStream = FSys.CreateTextFile(TestFile, True, False)
- OutStream.WriteLine Text1.Text
- Set OutStream = Nothing
- End Sub
- Private Sub bttnReadFile_Click()
- Dim InStream As TextStream
- TestFile = App.Path & "\textfile.txt"
- Set InStream = FSys.OpenTextFile(TestFile, 1, False, False)
- While InStream.AtEndOfStream = False
- TLine = InStream.ReadLine
- txt = txt & TLine & vbCrLf
- Wend
- Text1.Text = "The following text was read from the file" & vbCrLf
- Text1.Text = Text1.Text & vbCrLf & String(50, "*")
- Text1.Text = Text1.Text & vbCrLf & txt
- Text1.Text = Text1.Text & vbCrLf & String(50, "*")
- Set InStream = Nothing
- End Sub
-