home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch20 / tstream / tstream.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-05-11  |  3.3 KB  |  99 lines

  1. VERSION 5.00
  2. Begin VB.Form TStreamForm 
  3.    Caption         =   "TextStream Object Demo"
  4.    ClientHeight    =   5775
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   9045
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   5775
  10.    ScaleWidth      =   9045
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton bttnReadFile 
  13.       Caption         =   "Read File"
  14.       BeginProperty Font 
  15.          Name            =   "Verdana"
  16.          Size            =   9.75
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   495
  24.       Left            =   7320
  25.       TabIndex        =   2
  26.       Top             =   5160
  27.       Width           =   1575
  28.    End
  29.    Begin VB.TextBox Text1 
  30.       BeginProperty Font 
  31.          Name            =   "Verdana"
  32.          Size            =   9
  33.          Charset         =   0
  34.          Weight          =   400
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       Height          =   4815
  40.       Left            =   120
  41.       MultiLine       =   -1  'True
  42.       ScrollBars      =   2  'Vertical
  43.       TabIndex        =   1
  44.       Text            =   "TStream.frx":0000
  45.       Top             =   120
  46.       Width           =   8775
  47.    End
  48.    Begin VB.CommandButton bttnCreateFile 
  49.       Caption         =   "Create File"
  50.       BeginProperty Font 
  51.          Name            =   "Verdana"
  52.          Size            =   9.75
  53.          Charset         =   0
  54.          Weight          =   400
  55.          Underline       =   0   'False
  56.          Italic          =   0   'False
  57.          Strikethrough   =   0   'False
  58.       EndProperty
  59.       Height          =   495
  60.       Left            =   5640
  61.       TabIndex        =   0
  62.       Top             =   5160
  63.       Width           =   1575
  64.    End
  65. Attribute VB_Name = "TStreamForm"
  66. Attribute VB_GlobalNameSpace = False
  67. Attribute VB_Creatable = False
  68. Attribute VB_PredeclaredId = True
  69. Attribute VB_Exposed = False
  70. '  ******************************
  71. '  ******************************
  72. '  ** MASTERING VB6            **
  73. '  ** by Evangelos Petroutos   **
  74. '  ** SYBEX, 1998              **
  75. '  ******************************
  76. '  ******************************
  77. Dim FSys As New FileSystemObject
  78. Private Sub bttnCreateFile_Click()
  79. Dim OutStream As TextStream
  80.     TestFile = App.Path & "\textfile.txt"
  81.     Set OutStream = FSys.CreateTextFile(TestFile, True, False)
  82.     OutStream.WriteLine Text1.Text
  83.     Set OutStream = Nothing
  84. End Sub
  85. Private Sub bttnReadFile_Click()
  86. Dim InStream As TextStream
  87.     TestFile = App.Path & "\textfile.txt"
  88.     Set InStream = FSys.OpenTextFile(TestFile, 1, False, False)
  89.     While InStream.AtEndOfStream = False
  90.         TLine = InStream.ReadLine
  91.         txt = txt & TLine & vbCrLf
  92.     Wend
  93.     Text1.Text = "The following text was read from the file" & vbCrLf
  94.     Text1.Text = Text1.Text & vbCrLf & String(50, "*")
  95.     Text1.Text = Text1.Text & vbCrLf & txt
  96.     Text1.Text = Text1.Text & vbCrLf & String(50, "*")
  97.     Set InStream = Nothing
  98. End Sub
  99.