practice12_2.frm

来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 114 行

FRM
114
字号
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3375
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5970
   LinkTopic       =   "Form1"
   ScaleHeight     =   3375
   ScaleWidth      =   5970
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command4 
      Caption         =   "退出"
      Height          =   495
      Left            =   4440
      TabIndex        =   5
      Top             =   2640
      Width           =   1095
   End
   Begin VB.CommandButton Command3 
      Caption         =   "保存"
      Height          =   495
      Left            =   3120
      TabIndex        =   4
      Top             =   2640
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "计算"
      Height          =   495
      Left            =   1800
      TabIndex        =   3
      Top             =   2640
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "显示"
      Height          =   495
      Left            =   480
      TabIndex        =   2
      Top             =   2640
      Width           =   1095
   End
   Begin VB.TextBox Text2 
      Height          =   1095
      Left            =   360
      MultiLine       =   -1  'True
      ScrollBars      =   1  'Horizontal
      TabIndex        =   1
      Top             =   1440
      Width           =   5175
   End
   Begin VB.TextBox Text1 
      Height          =   1095
      Left            =   360
      MultiLine       =   -1  'True
      ScrollBars      =   1  'Horizontal
      TabIndex        =   0
      Top             =   240
      Width           =   5295
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   0
      Top             =   2640
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Num(1 To 100) As String, Nam(1 To 100) As String
Dim G(1 To 100, 1 To 3) As Integer, Ave(1 To 100) As Single, N As Integer
Private Sub Command1_Click()    ' 显示
  CommonDialog1.ShowOpen
  Open CommonDialog1.FileName For Input As #2
  N = 0
  Do While Not EOF(2)
    N = N + 1
    Input #2, Num(N), Nam(N), G(N, 1), G(N, 2), G(N, 3)
    Text1.Text = Text1.Text & "   " & Num(N) & _
      "  " & Nam(N) & "   " & Str(G(N, 1)) & _
      "   " & Str(G(N, 2)) & "   " & Str(G(N, 3)) & Chr(13) & Chr(10)
  Loop
End Sub
Private Sub Command2_Click()   ' 计算
  Sum1 = 0
  Sum2 = 0
  Sum3 = 0
  Text2.Text = ""
  For i = 1 To N
    Ave(i) = (G(i, 1) + G(i, 2) + G(i, 3)) / 3
    Text2.Text = Text2.Text & "   " & Num(i) & _
        "  " & Nam(i) & "   " & Str(G(i, 1)) & "   " & _
        Str(G(i, 2)) & "   " & Str(G(i, 3)) & "   " & Str(Ave(i)) & vbCrLf
  Next i
End Sub
Private Sub Command3_Click()   ' 保存
  CommonDialog1.ShowSave
  Open CommonDialog1.FileName For Output As #3
  For i = 1 To N
    Write #3, Num(i), Nam(i), Ave(i)
  Next i
  MsgBox "保存完成"
End Sub
Private Sub Command4_Click()
  Close #2, #3
  End
End Sub

⌨️ 快捷键说明

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