⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmcreating.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Begin VB.Form frmCreating 
   Caption         =   "Fig. 14.17: Writing to a sequential file"
   ClientHeight    =   2685
   ClientLeft      =   2760
   ClientTop       =   2145
   ClientWidth     =   4785
   LinkTopic       =   "Form1"
   ScaleHeight     =   2685
   ScaleWidth      =   4785
   Begin VB.Frame Frame1 
      Caption         =   "Account Information"
      Height          =   2055
      Left            =   90
      TabIndex        =   4
      Top             =   75
      Width           =   3210
      Begin VB.TextBox txtBalance 
         Height          =   375
         Left            =   1050
         TabIndex        =   2
         Top             =   1545
         Width           =   1980
      End
      Begin VB.TextBox txtName 
         Height          =   375
         Left            =   1050
         TabIndex        =   1
         Top             =   952
         Width           =   1980
      End
      Begin MSMask.MaskEdBox mskAccount 
         Height          =   375
         Left            =   1050
         TabIndex        =   0
         Top             =   360
         Width           =   1980
         _ExtentX        =   3493
         _ExtentY        =   661
         _Version        =   393216
         MaxLength       =   3
         Mask            =   "###"
         PromptChar      =   "_"
      End
      Begin VB.Label lblBalance 
         Caption         =   "Balance:"
         Height          =   390
         Left            =   135
         TabIndex        =   7
         Top             =   1560
         Width           =   1110
      End
      Begin VB.Label lblName 
         Caption         =   "Last Name:"
         Height          =   360
         Left            =   120
         TabIndex        =   6
         Top             =   975
         Width           =   1335
      End
      Begin VB.Label lblAccount 
         Caption         =   "Account:"
         Height          =   315
         Left            =   150
         TabIndex        =   5
         Top             =   435
         Width           =   1350
      End
   End
   Begin VB.CommandButton cmdWrite 
      Caption         =   "Write"
      Height          =   495
      Left            =   3465
      TabIndex        =   3
      Top             =   1650
      Width           =   1215
   End
   Begin VB.Label lblFileName 
      BorderStyle     =   1  'Fixed Single
      Height          =   345
      Left            =   90
      TabIndex        =   8
      Top             =   2280
      Width           =   4590
   End
End
Attribute VB_Name = "frmCreating"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 14.17
' Writing to a sequential text file
Option Explicit                          ' General declaration
Dim mFileSysObj As New FileSystemObject  ' General declaration
Dim mFile As File                        ' General declaration
Dim mTxtStream As TextStream             ' General declaration

Private Sub Form_Load()

   ' Create a text file
   Call mFileSysObj.CreateTextFile("..\clients.dat")
   
   ' Once file is created, reference the file
   Set mFile = mFileSysObj.GetFile("..\clients.dat")
   
   ' Open a text stream for writing to the file
   Set mTxtStream = mFile.OpenAsTextStream(ForWriting)
   
   ' Display path in lblFileName
   lblFileName.Caption = mFile.Path
End Sub

Private Sub cmdWrite_Click()

   ' Write the data to the file
   Call mTxtStream.WriteLine(mskAccount.Text & " " & _
                             txtName.Text & " " & _
                             txtBalance.Text)
                             
   ' Clear MaskEdit and TextBoxes
   txtName.Text = ""
   txtBalance.Text = ""
   
   ' Set several properties for mskAccount
   ' using With statement
   With mskAccount
      .Text = "000"     ' Display all zeros in MaskEdit
      .SelStart = 0     ' Start highlighting at position 0
      .SelLength = 3    ' Highlight 3 characters
      .SetFocus         ' Transfer focus
   End With
End Sub

Private Sub Form_Terminate()
   Call mTxtStream.Close     ' Close the text stream
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -