1. 程式人生 > >學生資訊管理系統之查:查詢成績資訊流程

學生資訊管理系統之查:查詢成績資訊流程

查詢成績資訊流程圖:

這裡寫圖片描述

查詢成績資訊程式碼部分

一、myflesgrid資料載入

 With myflexgrid
        .CellAlignment = 4           '對齊方式中中對齊
        .TextMatrix(1, 0) = "考試編號"
        .TextMatrix(1, 1) = "學號"
        .TextMatrix(1, 2) = "姓名"
        .TextMatrix(1, 3) = "班號"
        .TextMatrix(1, 4) = "課程名稱"
        .TextMatrix(1
, 5) = "分數" End With

二、檢測查詢方式

txtSQL = "select * from result_Info where "
    If Check1(0).Value Then
    ......
    End If

    If Check1(1).Value Then
    ......
    End If

     If Check1(2).Value Then
    ......
    End If

三、判斷文字框是否為空,是否為數字

If Trim(txtSID.Text) = "" Then
            sMeg = "學號不能為空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告" txtSID.SetFocus Exit Sub Else If Not IsNumeric(Trim(txtSID.Text)) Then MsgBox "請輸入數字!", vbOKOnly + vbExclamation, "警告" Exit Sub txtSID.SetFocus End
If dd(0) = True txtSQL = txtSQL & "student_ID='" & Trim(txtSID.Text) & "'" End If

四、各查詢方式的疊加

Dim dd(4) As Boolean
    If Check1(0).Value Then
        If ...
        Else...
            dd(0) = True
            txtSQL = txtSQL & "student_ID='" & Trim(txtSID.Text) & "'"
        End If
    End If

    If Check1(1).Value Then
        If...
        Else...
            dd(1) = True
            If dd(0) Then
                txtSQL = txtSQL & "and student_Name='" & txtName.Text & "'"
            Else
                txtSQL = txtSQL & "student_Name='" & txtName.Text & "'"
            End If
        End If
    End If

    If Check1(2).Value Then
        If ...
        Else
            dd(2) = True
            If dd(0) Or dd(1) Then
                txtSQL = txtSQL & "and course_Name='" & txtCourse.Text & "'"
            Else
                txtSQL = txtSQL & "course_Name='" & txtCourse.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

查詢成績資訊窗體的特點:多項選擇的查詢。

這就涉及到了多項查詢資料庫內多個內容的銜接,它的邏輯是我們要著重梳理的。