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

📄 form1.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "Initialize a Random-Access File"
   ClientHeight    =   510
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4710
   LinkTopic       =   "Form1"
   ScaleHeight     =   510
   ScaleWidth      =   4710
   StartUpPosition =   3  'Windows Default
   Begin MSComDlg.CommonDialog dlgOpen 
      Left            =   2160
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      DialogTitle     =   "Specify File to Create"
      Filter          =   "Random-access files (*.rnd) | *.rnd"
      InitDir         =   "c:\"
   End
   Begin VB.CommandButton cmdInitialize 
      Caption         =   "Click here to initialize a random-access file"
      Height          =   495
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   3375
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "Exit"
      Height          =   495
      Left            =   3480
      TabIndex        =   0
      Top             =   0
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 15.4
' Creating a blank random-access file
Option Explicit

Private Type ClientRecord
   accountNumber As Integer
   lastName As String * 15
   firstName As String * 15
   balance As Currency
End Type

Sub cmdInitialize_Click()
   Dim recordLength As Long, x As Integer
   Dim udtBlankClient As ClientRecord   ' user defined type
   Dim filename As String
   
   ' Determine number of bytes in a ClientRecord object
   recordLength = LenB(udtBlankClient)
   
   dlgOpen.ShowOpen
   filename = dlgOpen.filename
   
   If dlgOpen.FileTitle <> "" Then
      ' Open clients.rnd for writing
      Open filename For Random Access Write As #1 _
         Len = recordLength

      For x = 1 To 100
         Put #1, x, udtBlankClient  ' Write empty records
      Next

      Close #1   ' Close file

      cmdInitialize.Enabled = False  ' Disable button
      MsgBox ("File initialized. Click Exit to terminate.")
   Else
      MsgBox ("You must specify a file name")
   End If
End Sub

Sub cmdExit_Click()
   End
End Sub

⌨️ 快捷键说明

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