frmrfile.frm

来自「VB6.0应用例题」· FRM 代码 · 共 88 行

FRM
88
字号
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "读写随机文件"
   ClientHeight    =   2415
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4875
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2415
   ScaleWidth      =   4875
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton CmdOutput 
      Caption         =   "输出记录"
      Height          =   495
      Left            =   3240
      TabIndex        =   3
      Top             =   1680
      Width           =   1095
   End
   Begin VB.CommandButton CmdAppend 
      Caption         =   "追加记录"
      Height          =   495
      Left            =   1800
      TabIndex        =   2
      Top             =   1680
      Width           =   1095
   End
   Begin VB.CommandButton CmdNew 
      Caption         =   "新建文件"
      Height          =   495
      Left            =   360
      TabIndex        =   1
      Top             =   1680
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   975
      Left            =   600
      TabIndex        =   0
      Top             =   360
      Width           =   3495
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Type ShuJu
  Name As String * 10
  Tel As String * 10
End Type
Dim Ren As ShuJu
Dim n As Integer
Private Sub CmdNew_Click()
  Open "address.txt" For Random As #1 Len = Len(Ren)
  n = InputBox("人数?")
  For i = 1 To n
    Ren.Name = InputBox("Input name:")
    Ren.Tel = InputBox("Input Tel.NO:")
    Put #1, i, Ren
  Next i
  Close #1
End Sub
Private Sub CmdAppend_Click()
  Open "address.txt" For Random As #1 Len = Len(Ren)
  n = LOF(1) / Len(Ren)     'LOF函数返回文件的字节数
  m = InputBox("追加几条记录?")
  For i = 1 To m
    Ren.Name = InputBox("Input name:")
    Ren.Tel = InputBox("Input Tel.NO:")
    Put #1, n + i, Ren
  Next i
  Close #1
End Sub
Private Sub CmdOutput_Click()
  Open "address.txt" For Random As #1 Len = Len(Ren)
  i = InputBox("输出第几条记录")
  Get #1, i, Ren
  Text1.Text = Ren.Name + Ren.Tel
  Close #1
End Sub

⌨️ 快捷键说明

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