pexam12_5.frm

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

FRM
151
字号
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3555
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6195
   LinkTopic       =   "Form1"
   ScaleHeight     =   3555
   ScaleWidth      =   6195
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "退出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4440
      TabIndex        =   4
      Top             =   2760
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "计算平均"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2520
      TabIndex        =   3
      Top             =   2760
      Width           =   1695
   End
   Begin VB.CommandButton Command1 
      Caption         =   "装入数据"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   720
      TabIndex        =   2
      Top             =   2760
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1095
      Left            =   360
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   1
      Top             =   1440
      Width           =   5535
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1095
      Left            =   360
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   240
      Width           =   5535
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   120
      Top             =   2760
      _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(100) As String, Nam(100) As String
Dim G(100, 2) As Integer, N As Integer
Private Sub Command1_Click()    ' 装入数据
  CommonDialog1.ShowOpen
  Open CommonDialog1.FileName For Input As #3
  N = 0
  Do While Not EOF(3)
    N = N + 1
    Input #3, Num(N), Nam(N), G(N, 1), G(N, 2)
    Text1.Text = Text1.Text & "   " & Num(N) & _
      "  " & Nam(N) & "   " & Str(G(N, 1)) & _
      "   " & Str(G(N, 2)) & "   " & Chr(13) & Chr(10)
  Loop
End Sub
Private Sub Command2_Click()   ' 计算平均
  CommonDialog1.ShowSave
  Open CommonDialog1.FileName For Output As #4
  SUM1 = 0
  SUM2 = 0
  Text2.Text = ""
  For i = 1 To N
    Ave = (G(i, 1) + G(i, 2)) / 2
    Write #4, Num(i), Nam(i), G(i, 1), G(i, 2), Ave
    Text2.Text = Text2.Text & "   " & Num(i) & _
        "  " & Nam(i) & "   " & Str(G(i, 1)) & "   " & _
        Str(G(i, 2)) & "   " & Str(Ave) & vbCrLf
    SUM1 = SUM1 + G(i, 1): SUM2 = SUM2 + G(i, 2)
  Next i
 Text2.Text = Text2.Text & " 总平均" & " " & _
     Str(SUM1 / N) & "   " & Str(SUM2 / N)
  Write #4, "总平均", SUM1 / N, SUM2 / N
End Sub
Private Sub Command3_Click()   ' 退出
  Close #3, #4
  End
End Sub


⌨️ 快捷键说明

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