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

📄 frmmain.frm

📁 这是一本学习串口编程喝计算机监控的好书里面是用VB开发的源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmMain 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "教学计划计算器"
   ClientHeight    =   2235
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6495
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   2235
   ScaleWidth      =   6495
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton txtCalculate 
      Caption         =   "计算"
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5400
      TabIndex        =   4
      Top             =   1680
      Width           =   855
   End
   Begin VB.TextBox txtStart 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1680
      MaxLength       =   1
      TabIndex        =   1
      Top             =   720
      Width           =   495
   End
   Begin VB.CommandButton cmdClear 
      Caption         =   "清除"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4320
      TabIndex        =   5
      Top             =   1680
      Width           =   735
   End
   Begin VB.TextBox txtResult 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1680
      TabIndex        =   6
      Top             =   1200
      Width           =   4575
   End
   Begin VB.TextBox txtDouble 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5280
      MaxLength       =   1
      TabIndex        =   3
      Top             =   720
      Width           =   495
   End
   Begin VB.TextBox txtSingle 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3360
      MaxLength       =   1
      TabIndex        =   2
      Top             =   720
      Width           =   495
   End
   Begin VB.TextBox txtSource 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1680
      TabIndex        =   0
      Top             =   240
      Width           =   4575
   End
   Begin VB.Label Label8 
      Alignment       =   2  'Center
      Caption         =   "周"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2160
      TabIndex        =   14
      Top             =   840
      Width           =   375
   End
   Begin VB.Label Label7 
      Alignment       =   2  'Center
      Caption         =   "起始:第"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   600
      TabIndex        =   13
      Top             =   840
      Width           =   975
   End
   Begin VB.Label Label6 
      Alignment       =   2  'Center
      Caption         =   "计算结果:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   12
      Top             =   1320
      Width           =   975
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      Caption         =   "学时"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5760
      TabIndex        =   11
      Top             =   840
      Width           =   495
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      Caption         =   "双周"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4800
      TabIndex        =   10
      Top             =   840
      Width           =   495
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "学时"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3840
      TabIndex        =   9
      Top             =   840
      Width           =   495
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Caption         =   "单周"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2880
      TabIndex        =   8
      Top             =   840
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "章学时清单:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   360
      Width           =   1575
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim nCourse() As Integer
Dim nResult() As Integer
Dim nChapters As Integer
Dim nStart As Integer
Dim nSingle As Integer
Dim nDouble As Integer

Private Sub cmdClear_Click()
    txtSource.Text = ""
    txtStart.Text = ""
    txtSingle.Text = ""
    txtDouble.Text = ""
    txtResult.Text = ""
End Sub

Private Sub txtCalculate_Click()
    Dim I As Integer
    Dim nCurWeek As Integer
    
    If txtSource.Text = "" Or txtStart.Text = "" Or (txtSingle.Text = "" And txtDouble.Text = "") Then
        MsgBox "Please input data at first!", vbCritical + vbOKOnly
        Exit Sub
    End If
    
    nChapters = FeatureCount(txtSource.Text, " ")
    If nChapters < 1 Then
        MsgBox "Please input more data!", vbExclamation + vbOKOnly
        Exit Sub
    End If
    
    txtResult.Text = ""
    ReDim nCourse(nChapters)
    ReDim nResult(nChapters)
    
    nSingle = Val(txtSingle.Text)
    nDouble = Val(txtDouble.Text)
    nStart = Val(txtStart.Text)
    
    If (nDouble < 1 And nSingle < 1) Or nStart = 0 Then
        MsgBox "Data error!", vbCritical + vbOKOnly
        Exit Sub
    End If
    
    For I = 0 To nChapters
        nCourse(I) = Val(GetNoString(txtSource.Text, " ", I))
        If I = 0 Then
            nResult(I) = nStart
            nCurWeek = nStart
        Else
            Do While True
                If nCurWeek Mod 2 = 1 Then 'single week
                    If nCourse(I - 1) >= nSingle Then
                        nCourse(I - 1) = nCourse(I - 1) - nSingle
                        nCurWeek = nCurWeek + 1
                    Else
                        nResult(I) = nCurWeek
                        nCourse(I) = nCourse(I) + nCourse(I - 1)
                        Exit Do
                    End If
                Else                'double week
                    If nCourse(I - 1) >= nDouble Then
                        nCourse(I - 1) = nCourse(I - 1) - nDouble
                        nCurWeek = nCurWeek + 1
                    Else
                        nResult(I) = nCurWeek
                        nCourse(I) = nCourse(I) + nCourse(I - 1)
                        Exit Do
                    End If
                End If
            Loop
        End If
        txtResult.Text = txtResult.Text + ts(I + 1) + "-" + ts(nResult(I)) + "/"
    Next I
End Sub

⌨️ 快捷键说明

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