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

📄 form2.frm

📁 VB 学生管理系统,实习时候用的。现在传上来给大家看看。菜鸟作品
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "用户身份验证"
   ClientHeight    =   2970
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6015
   LinkTopic       =   "Form2"
   Picture         =   "Form2.frx":0000
   ScaleHeight     =   2970
   ScaleWidth      =   6015
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command2 
      BackColor       =   &H8000000E&
      Height          =   495
      Left            =   3600
      Picture         =   "Form2.frx":19DB8
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2040
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H8000000E&
      Height          =   495
      Left            =   2640
      MaskColor       =   &H00FFFFFF&
      Picture         =   "Form2.frx":1CC45
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   2040
      Width           =   975
   End
   Begin VB.TextBox Text2 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2520
      PasswordChar    =   "*"
      TabIndex        =   1
      Top             =   1440
      Width           =   2055
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   2520
      TabIndex        =   0
      Top             =   840
      Width           =   2055
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer

Private Sub Command1_Click()
    If Trim(Text1.Text) = "" Then
        MsgBox "请输入用户名", vbExclamation, "注意"
        Text1.SetFocus
    Else
        On Error GoTo er
        mycon.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" & Trim(Text1.Text) & ";password=" & Trim(Text2.Text) & ";Initial Catalog=学生管理;Data Source=G501-2"
        mycon.Open
        Unload Me
        Form3.Show
    End If
    Exit Sub
er:
    i = i + 1
    If i <= 2 Then
        MsgBox "连接失败,请重新输入用户名或密码", vbExclamation, "注意"
        Text1.SetFocus
        Else
            MsgBox "输入失败过多,你不能使用本系统", vbExclamation, "注意"
            End
        End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub


Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    Text2.SetFocus
End If
End Sub

Private Sub Text2_GotFocus()
    Text2.SelStart = 0
    Text2.SelLength = Len(Text2.Text)
End Sub

Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If Trim(Text1.Text) = "" Then
    MsgBox "请输入用户名", vbExclamation, "注意"
     Text1.SetFocus
Else
    On Error GoTo er
     mycon.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" & Trim(Text1.Text) & ";password=" & Trim(Text2.Text) & ";Initial Catalog=学生管理;Data Source=G501-2"
    mycon.Open
    Unload Me
    Form3.Show
End If
Exit Sub
er:
    i = i + 1
    If i <= 2 Then
        MsgBox "连接失败,请重试用户名或密码", vbExclamation, "注意"
        Text1.SetFocus
    Else
        MsgBox "输入失败过多,你不能使用本系统!", vbExclamation, "注意"
        End
    End If
End If
End Sub

⌨️ 快捷键说明

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