frmdl.frm

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

FRM
250
字号
VERSION 5.00
Begin VB.Form Frmdl 
   Caption         =   "考生登录"
   ClientHeight    =   3750
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3735
   Icon            =   "Frmdl.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3750
   ScaleWidth      =   3735
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Cmdml 
      Caption         =   "正确无误"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   960
      TabIndex        =   6
      Top             =   3000
      Width           =   1695
   End
   Begin VB.TextBox Txtzwh 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1800
      TabIndex        =   4
      Top             =   1800
      Width           =   1500
   End
   Begin VB.TextBox Txtname 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1800
      TabIndex        =   5
      Top             =   1200
      Width           =   1500
   End
   Begin VB.TextBox Txtcode 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1800
      MaxLength       =   8
      TabIndex        =   3
      Top             =   600
      Width           =   1500
   End
   Begin VB.Label Lblsm 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   360
      TabIndex        =   7
      Top             =   2520
      Width           =   3255
   End
   Begin VB.Label Label3 
      Caption         =   "座位号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   600
      TabIndex        =   2
      Top             =   1920
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "考核证号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   480
      TabIndex        =   1
      Top             =   600
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "姓  名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   600
      TabIndex        =   0
      Top             =   1200
      Width           =   975
   End
End
Attribute VB_Name = "Frmdl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdml_Click()
Dim ksindex As String
    If Len(Txtcode.Text) < 8 Then
       Lblsm.Caption = "准考证号必须输入,长度为8位"
       Txtcode.SetFocus
    ElseIf Len(Txtname.Text) = 0 Then
           Lblsm.Caption = "考生姓名必须输入"
           Txtname.SetFocus
           Exit Sub
    ElseIf Len(Txtzwh.Text) = 0 Then
           Lblsm.Caption = "座位号必须输入"
           Txtzwh.SetFocus
           Exit Sub
    End If
    Lblsm.Caption = ""
    ksindex = Txtcode.Text & "," & Txtname.Text & "," & Txtzwh.Text
    Open setuppath & "\inde.txt" For Output As #1
        Print #1, ksindex
    Close #1
    Frmxz.Show
    Unload Me

End Sub

Private Sub Form_Load()
ReDim code(6) As String
Dim i            As Integer
Dim tnum         As String
Dim ksname       As String
On Error Resume Next
    
    setuppath = Space(255)
    i = GetPrivateProfileString("XxjcTest", "Workpath", "C:\XxjcTest", setuppath, Len(setuppath), "XxjcTest.ini")
    stnum = GetPrivateProfileInt("XxjcTest", "tiNum", 1, "XxjcTest.ini")
    setuppath = Left(Trim(setuppath), Len(Trim(setuppath)) - 1)
    Open setuppath & "\inde.txt" For Input As #1
    If Err = 0 Then
        For i = 1 To 3
          Input #1, code(i)
        Next i
    ElseIf Err <> 53 Then
        MsgBox Error(Err), 48
        End
    End If
    Close #1
    If code(1) <> "" Then
       Txtcode.Text = LTrim$(RTrim$(code(1)))
       Txtname.Text = LTrim$(RTrim$(code(2)))
       Txtzwh.Text = LTrim$(RTrim$(code(3)))
    End If
    CenterOnSetupForm Me

End Sub

Private Sub Txtcode_LostFocus()
    If Len(Txtcode.Text) < 8 Then
       Lblsm.Caption = "准考证号必须输入,长度为8位!"
       Txtcode.SetFocus
    ElseIf Not IsNumeric(Txtcode.Text) Then
       Lblsm.Caption = "准考证号必须是数字!"
       Txtcode.SetFocus
    Else
        Lblsm.Caption = ""
        Txtname.SetFocus
    End If

End Sub

Private Sub Txtname_LostFocus()
    If Len(Txtcode.Text) < 8 Or Not IsNumeric(Txtcode.Text) Then
       Txtcode.SetFocus
    ElseIf Len(Txtname.Text) = 0 Then
       Lblsm.Caption = "考生姓名必须输入!"
       Txtname.SetFocus
    Else
        Lblsm.Caption = ""
        Txtzwh.SetFocus
    End If

End Sub

Private Sub Txtzwh_LostFocus()
    If Len(Txtname.Text) = 0 Then
       Txtname.SetFocus
    ElseIf Len(Txtzwh.Text) = 0 Then
       Lblsm.Caption = "座位号必须输入!"
       Txtzwh.SetFocus
    ElseIf Not IsNumeric(Txtzwh.Text) Then
       Lblsm.Caption = "座位号必须是数字"
       Txtzwh.SetFocus
    Else
        Lblsm.Caption = ""
        Cmdml.SetFocus
    End If

End Sub

⌨️ 快捷键说明

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