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

📄 数据文件f2(窗体模块frmtext).frm

📁 这个程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmText 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "使用文本框录入或编辑"
   ClientHeight    =   8430
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   12750
   LinkTopic       =   "Form1"
   ScaleHeight     =   8430
   ScaleWidth      =   12750
   Begin VB.TextBox txtCol 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Index           =   0
      Left            =   720
      TabIndex        =   5
      Top             =   240
      Width           =   735
   End
   Begin VB.TextBox txtRow 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Index           =   0
      Left            =   0
      TabIndex        =   4
      Top             =   480
      Width           =   735
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Height          =   255
      Left            =   1440
      TabIndex        =   3
      TabStop         =   0   'False
      ToolTipText     =   "结束程序运行"
      Top             =   0
      Width           =   735
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "打印"
      Height          =   255
      Left            =   720
      TabIndex        =   2
      TabStop         =   0   'False
      ToolTipText     =   "打印机打印录入数据"
      Top             =   0
      Width           =   735
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   255
      Left            =   0
      TabIndex        =   1
      TabStop         =   0   'False
      ToolTipText     =   "将录入数据保存到数据文件"
      Top             =   0
      Width           =   855
   End
   Begin VB.TextBox txtDat 
      Appearance      =   0  'Flat
      Height          =   270
      Index           =   0
      Left            =   720
      TabIndex        =   0
      Top             =   480
      Width           =   735
   End
End
Attribute VB_Name = "frmText"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'文本框窗体
Option Explicit
Dim sngtxtHig As Single, sngtxtWid As Single
Dim snglblHig As Single, snglblWid As Single
Dim intI As Integer, intJ As Integer
Dim strA As String

Private Sub Form_Load()
    intCol = intCol * 2                             '每一列都有初值和终值两个值
    Me.Height = Screen.Height
    Me.Width = Screen.Width
'使设计时安置在窗体的原型控件不可见
    txtDat(0).Visible = False
    txtRow(0).Visible = False
    txtCol(0).Visible = False
'利用原型控件的坐标参数
    sngtxtHig = txtDat(0).Height
    sngtxtWid = txtDat(0).Width
    snglblHig = sngtxtHig                           '原型控件的高度
    snglblWid = sngtxtWid                           '原型控件的宽度
'形成文本框数组
    For intI = 1 To intRow
        For intJ = 1 To intCol
            If intEdit = 1 Then _
                Input #intFileNumber, strA          '编辑时读数据
            Load txtDat((intI - 1) * intCol + intJ)
            txtDat((intI - 1) * intCol + intJ).Move _
                             txtDat(0).Left + (intJ - 1) * sngtxtWid, _
                             txtDat(0).Top + (intI - 1) * sngtxtHig
            txtDat((intI - 1) * intCol + intJ).Visible = True
            If intEdit = 1 Then                     '编辑时
                txtDat((intI - 1) * intCol + intJ).Text = strA
            Else                                    '新建时
                txtDat((intI - 1) * intCol + intJ).Text = ""
            End If
        Next intJ
    Next intI
'形成左边文本框数组,对行作标记
    For intI = 1 To intRow
        Load txtRow(intI)
        txtRow(intI).Move txtRow(0).Left, _
            txtRow(0).Top + (intI - 1) * sngtxtHig
        txtRow(intI).Visible = True
        txtRow(intI).Text = intI & "行"
    Next intI
'形成上边文本框数组,对列作标记
    For intI = 1 To intCol
        Load txtCol(intI)
        txtCol(intI).Move txtCol(0).Left + (intI - 1) * snglblWid, _
                          txtCol(0).Top
        txtCol(intI).Visible = True
        If (intI \ 2) * 2 = intI Then
            txtCol(intI).Text = "终值"
        Else
            txtCol(intI).Text = "初值"
        End If
    Next intI
    Close #intFileNumber
End Sub

'打印
Private Sub cmdPrint_Click()
    Dim intI1 As Integer, intI2 As Integer
    intI1 = 1: intI2 = 8
    If intCol <= 8 Then intI2 = intCol
    Printer.Print
AA1:
    Printer.Print ,
    For intI = intI1 To intI2
        Printer.Print txtCol(intI).Text,            '打印列标记
    Next intI
    For intI = 1 To intRow
        Printer.Print
        Printer.Print txtRow(intI).Text,            '打印行标记
        For intJ = intI1 To intI2
'打印数据
            Printer.Print txtDat((intI - 1) * intCol + intJ).Text,
        Next intJ
    Next intI
    If intCol > 8 And intI2 <= 8 Then
        intI1 = intI1 + 8
        intI2 = intCol
        Printer.Print
        Printer.Print
        GoTo AA1
    End If
    Printer.EndDoc                                  '执行打印
End Sub


'保存为数据文件
Private Sub cmdSave_Click()
    Dim intFileNumber As Integer
    MsgBox "开始保存数据,请耐心等待!"
    intFileNumber = FreeFile                        '取得空闲的文件号
    Open strFileName For Output As intFileNumber    '打开文件
    Write #intFileNumber, intRow; intCol / 2        '保存行数和列数
    For intI = 1 To intRow
        For intJ = 1 To intCol
'将数组中的数据写到文件
            strA = txtDat((intI - 1) * intCol + intJ)
            If intJ <> intCol Then
                Write #intFileNumber, strA;
            Else
                Write #intFileNumber, strA
            End If
        Next intJ
    Next intI
'将上部的标签内容写到文件
    For intI = 1 To intCol
        strA = txtCol(intI).Text
        If intI <> intCol Then
            Write #intFileNumber, strA;
        Else
            Write #intFileNumber, strA
        End If
    Next intI
'将左边的标签内容写到文件
    For intI = 1 To intRow
        strA = txtRow(intI).Text
        If intI <> intRow Then
            Write #intFileNumber, strA;
        Else
            Write #intFileNumber, strA
        End If
    Next intI
    Close                                           '关闭文件
    cmdSave.Visible = False
    MsgBox "保存数据完成,请继续进行!"
End Sub

'退出
Private Sub cmdExit_Click()
    Unload Me
    End
End Sub





⌨️ 快捷键说明

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