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

📄 frmstudentinfo.frm

📁 这是一个选课系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Stretch         =   -1  'True
      Top             =   480
      Width           =   285
   End
   Begin VB.Image imgTitleLeft 
      Height          =   450
      Left            =   120
      Picture         =   "frmstudentinfo.frx":4EF9
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgTitleRight 
      Height          =   450
      Left            =   480
      Picture         =   "frmstudentinfo.frx":5643
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowBottomLeft 
      Height          =   450
      Left            =   840
      Picture         =   "frmstudentinfo.frx":5D8D
      Top             =   0
      Width           =   285
   End
   Begin VB.Image imgWindowBottomRight 
      Height          =   450
      Left            =   1200
      Picture         =   "frmstudentinfo.frx":64D7
      Top             =   0
      Width           =   285
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "查询条件:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   840
      Width           =   1455
   End
End
Attribute VB_Name = "frmstudentinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit
Dim txtSQL As String

Private Sub Form_Load()
  MakeWindow Me
  SmartNetXpButton4.Enabled = False
  Dim mrc As ADODB.Recordset
  Dim MsgText As String
  Dim i As Integer
  txtSQL = "select  sno,sname from student"
  Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
 On Error Resume Next
 For i = 0 To mrc.RecordCount - 1
  Combo1.AddItem mrc.Fields(0)
  Combo2.AddItem mrc.Fields(1)

  mrc.MoveNext
 Next i
mrc.Close
 txtSQL = "select distinct sgra from student order by sgra desc"
 Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
 On Error Resume Next
 For i = 0 To mrc.RecordCount - 1
   Combo3.AddItem mrc.Fields(0)
  mrc.MoveNext
 Next i
 mrc.Close
 txtSQL = "select distinct scol from student"
  Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
  On Error Resume Next
   For i = 0 To mrc.RecordCount - 1
     Combo4.AddItem mrc.Fields(0)
     mrc.Close
   Next i
 mrc.Close
 
End Sub


'Private Sub imgTitleClose_Click()
  '  intNumField = -2
    'Unload Me
'End Sub

  


Private Sub imgTitleLeft_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub

Private Sub imgTitleMain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub

Private Sub imgTitleMinimize_Click()
    Me.WindowState = 1
End Sub

Private Sub imgTitleRight_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub

Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoDrag Me
End Sub

Private Sub SmartNetXpButton1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
   Dim MsgText As String
    Dim dd(3) As Boolean
    Dim mrc As ADODB.Recordset
    Dim rs As Boolean
    Dim sMeg As String
    rs = True
       
    On Error Resume Next
    
    txtSQL = "select * from student where "
    If Check1.Value Then
        If Trim(Combo1.Text) = "" Then
            sMeg = "学号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo1.SetFocus
            Exit Sub
        Else
            
            dd(0) = True
            txtSQL = txtSQL & "Sno = '" & Trim(Combo1.Text) & "'"
        End If
    End If
    
    If Check2.Value Then
        If Trim(Combo2.Text) = "" Then
            sMeg = "姓名不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo2.SetFocus
            Exit Sub
        Else
            dd(1) = True
            If dd(0) Then
                txtSQL = txtSQL & "and Sname= '" & Trim(Combo2.Text) & "'"
            Else
                txtSQL = txtSQL & " Sname= '" & Trim(Combo2.Text) & "'"
            End If
        End If
    End If
    
    If Check3.Value Then
        If Trim(Combo3.Text) = "" Then
            sMeg = "学生所属年级"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo3.SetFocus
            Exit Sub
        Else
            dd(2) = True
            If dd(0) Or dd(1) Then
                txtSQL = txtSQL & "and Sgra= '" & Trim(Combo3.Text) & "'"
            Else
                txtSQL = txtSQL & " Sgra = '" & Trim(Combo3.Text) & "'"
            End If
        End If
    
    End If
    
    If Check4.Value Then
        If Trim(Combo4.Text) = "" Then
           sMeg = "请输入学生所属学院"
           MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
           Combo4.SetFocus
           Exit Sub
        Else
            dd(3) = True
            
            If dd(0) Or dd(1) Or dd(2) Then
               txtSQL = txtSQL & "and Scol='" & Trim(Combo4.Text) & "'"
            Else
               txtSQL = txtSQL & "Scol ='" & Trim(Combo4.Text) & " '"
            End If

         End If
    
    End If
    
    
    
    
    If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then
        MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If rs = True Then
    
       txtSQL = txtSQL & " order by Sno"
       Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
                            

       If mrc.RecordCount > 0 Then                     '设置打印功能
           SmartNetXpButton4.Enabled = True
        Else
           SmartNetXpButton4.Enabled = False
        End If
       With MSFlexGrid1
           .Rows = 2
           .CellAlignment = 4
           .TextMatrix(1, 1) = "学号"
           .TextMatrix(1, 2) = "姓名"
           .TextMatrix(1, 3) = "性别"
           .TextMatrix(1, 4) = "出生日期"
           .TextMatrix(1, 5) = "院别"
           .TextMatrix(1, 6) = "年级"
           .TextMatrix(1, 7) = "专业"
           .TextMatrix(1, 8) = "联系方式"
           .TextMatrix(1, 9) = "地址"
           .TextMatrix(1, 10) = "备注"
   
     
        
           
        Do While Not mrc.EOF
            
          
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 1) = mrc.Fields(0)
            .TextMatrix(.Rows - 1, 2) = mrc.Fields(1)
            .TextMatrix(.Rows - 1, 3) = mrc.Fields(2)
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(3)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 6) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(6)
            .TextMatrix(.Rows - 1, 8) = mrc.Fields(7)
            .TextMatrix(.Rows - 1, 9) = mrc.Fields(8)
            .TextMatrix(.Rows - 1, 10) = mrc.Fields(9)
            mrc.MoveNext
         Loop
        
       End With
    
    mrc.Close
   End If
End Sub

Private Sub SmartNetXpButton2_Click()
   Dim mrc As ADODB.Recordset
   Dim MsgText As String
  ' Dim txtstring As String
   SmartNetXpButton4.Enabled = True
    
   txtSQL = "select * from student order by Sno"
   Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)
   
    With MSFlexGrid1
           .Rows = 2
           .CellAlignment = 4
           .TextMatrix(1, 1) = "学号"
           .TextMatrix(1, 2) = "姓名"
           .TextMatrix(1, 3) = "性别"
           .TextMatrix(1, 4) = "出生日期"
           .TextMatrix(1, 5) = "院别"
           .TextMatrix(1, 6) = "年级"
           .TextMatrix(1, 7) = "专业"
           .TextMatrix(1, 8) = "联系方式"
           .TextMatrix(1, 9) = "地址"
           .TextMatrix(1, 10) = "备注"
   
     
        
           
        Do While Not mrc.EOF
            
          
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 1) = mrc.Fields(0)
            .TextMatrix(.Rows - 1, 2) = mrc.Fields(1)
            .TextMatrix(.Rows - 1, 3) = mrc.Fields(2)
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(3)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 6) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(6)
            .TextMatrix(.Rows - 1, 8) = mrc.Fields(7)
            .TextMatrix(.Rows - 1, 9) = mrc.Fields(8)
            .TextMatrix(.Rows - 1, 10) = mrc.Fields(9)
            mrc.MoveNext
         Loop
        
       End With
    
    mrc.Close
   
End Sub


Private Sub SmartNetXpButton3_Click()
   Unload Me
End Sub

Private Sub SmartNetXpButton4_Click()
    Dim i As Integer, j As Integer

    Dim MsgText As String
    Dim expworkbook As Excel.Workbook
    Dim expexcel As Excel.Application
    Dim mrc As ADODB.Recordset
    Set expexcel = New Excel.Application
    expexcel.Visible = True
    expexcel.SheetsInNewWorkbook = 1
    Set expworkbook = expexcel.Workbooks.Add

     Set mrc = MyDB.ExecuteSQL(txtSQL, MsgText)

    
    For i = 0 To mrc.Fields.Count - 1
        expexcel.Cells(2, i + 1) = mrc.Fields(i).Name
    Next
    mrc.MoveFirst
    For j = 1 To MSFlexGrid1.Rows
        For i = 0 To mrc.Fields.Count - 1
            expexcel.Cells(j + 2, i + 1) = CStr(mrc.Fields(i))
        Next
        mrc.MoveNext
        If mrc.EOF Then Exit For
    Next
        
    Set expexcel = Nothing
End Sub

⌨️ 快捷键说明

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