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

📄 pass_frm.frm

📁 高校学生选课系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form pass_frm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   3390
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4770
   Icon            =   "pass_frm.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3390
   ScaleWidth      =   4770
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   375
      Left            =   2640
      TabIndex        =   6
      Top             =   2520
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Height          =   375
      Left            =   840
      Picture         =   "pass_frm.frx":27A2
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   2520
      Width           =   1215
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      Left            =   2280
      TabIndex        =   1
      Text            =   "Combo1"
      Top             =   600
      Width           =   1455
   End
   Begin VB.TextBox Text1 
      Height          =   340
      IMEMode         =   3  'DISABLE
      Left            =   2280
      PasswordChar    =   "*"
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   1200
      Width           =   1440
   End
   Begin VB.Image Image1 
      Height          =   315
      Left            =   480
      Picture         =   "pass_frm.frx":4614
      Stretch         =   -1  'True
      Top             =   240
      Width           =   270
   End
   Begin VB.Label Label3 
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Label3"
      Height          =   15
      Left            =   480
      TabIndex        =   4
      Top             =   2160
      Width           =   3855
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "用户:"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   1080
      TabIndex        =   3
      Top             =   600
      Width           =   810
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Caption         =   "密码:"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   1080
      TabIndex        =   2
      Top             =   1110
      Width           =   735
   End
End
Attribute VB_Name = "pass_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim passtimes As Byte

Private Sub Combo1_Click()

Text1.SetFocus
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    Text1.SetFocus
  End If
End Sub

Private Sub Command1_Click()
'密码次数有点小问题,因为它不管用户名是否输错...当然可以把combo的style属性设置为2
 Dim str As String
 username = ""     '全局变量
 Dim sign As String
 sign = "警告"       'msgbox 中引用该字符串
 
 If Trim(Combo1.Text) = "" Then
 
     MsgBox "没有此用户,请重新输入用户名!", vbExclamation, sign
     Combo1.SetFocus
     Exit Sub
     
 Else
     str = "select * from 密码 where 用户名='" & Trim(Combo1.Text) & "'"
     rs.Open str, con, adOpenDynamic, adLockOptimistic, adCmdText
     If rs.EOF = True Then
     
        MsgBox "没有此用户,请重新输入!", vbExclamation, sign
        Combo1.Text = Empty
        Combo1.SetFocus
        rs.Close
        
     Else
     
        If Trim(Text1.Text) = Trim(rs.Fields(1)) Then   '合法用户进入系统
          username = Trim(Combo1.Text)   '在另一个模块中用(如mdiform1) ,
          oldpassword = Trim(Text1.Text)  '''全局变量
          rs.Close
          Unload pass_frm
          load_frm.Show
         
          
       Else  '密码出错
       
          passtimes = passtimes + 1
          MsgBox "密码不正确!请重新输入!", vbExclamation, sign
          Text1.SetFocus
          Text1.Text = ""
          rs.Close
          
       End If
       
            
        If passtimes = 3 Then
            MsgBox "你不是合法用户,请按确定退出!", vbExclamation, sign
            Unload Me
        End If
       
     End If
     
 End If
End Sub

Private Sub Command2_Click()
 Unload Me
End Sub

Private Sub Form_Load()
pass_frm.Move (Screen.Width - pass_frm.Width) / 2, (Screen.Height - pass_frm.Height) / 2
  Set rs = New ADODB.Recordset
  Dim str As String
  str = "select * from 密码"             '''''''''要改
  rs.Open str, con, adOpenDynamic, adLockOptimistic, adCmdText
   Do While rs.EOF = False      '默认的是:记录集位置为第一记录即当前记录
    Combo1.AddItem rs.Fields(0)  '添加数据库用户
    rs.MoveNext
  Loop
  rs.Close
  
  Text1.Text = ""
  Combo1.Text = ""
  passtimes = 0
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    Command1.SetFocus
  End If
End Sub

⌨️ 快捷键说明

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