【文章內(nèi)容簡介】
16 End If Exit Sub End Sub Private Sub Label1_Click() End Sub Private Sub txtPassword_KeyDown(KeyCode As Integer, Shift As Integer) EnterToTab KeyCode End Sub Private Sub txtPassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Call cmdOK_Click End If End Sub Private Sub txtUserName_Click() = End Sub Private Sub txtUserName_KeyDown(KeyCode As Integer, Shift As Integer) EnterToTab KeyCode End Sub 在工程中添加一個窗體,命名為“ dColor”。 整個窗體的界面設(shè)計示意圖如下 . dColor 窗體上的空間及其屬性如下表所示。 窗體屬性 設(shè)置值 具體說明 名稱 dColor 設(shè)置窗體名稱 MaxButton True 激活最大化按鈕 MinButton True 激活最小化按鈕 ControlBox True 控制按鈕 在登錄 窗體中添加控件,并設(shè)置控件的屬性如下表所示: 對象名 屬性 屬性值 Image1 Picture ( Bitmap) 17 Image2 Picture ( Bitmap) Stretch False Label1 Caption 歡迎進去學(xué)生管理系統(tǒng) BackColor 0 – Transparent 編寫窗體代碼 Private Sub Form_Load() = amp。H8000000E = 12 = True i = End Sub Private Sub Form_Resize() = 0 = 0 = = = = = 100 End Sub Private Sub Label1_Click() End Sub Private Sub Timer1_Timer() i = i + 50 = i If i + Then i = End If End Sub 在工程中添加一個窗體,命名為“ frmclai”。 整個窗體界面示意圖如圖所示 。 18 frmclai 窗體上的的主要屬性和控件設(shè)置如下: 對象名 屬性 屬性值 Frmclai Caption 班級信息 Minbutton True LinkTopic Form1 HacDC True MSFlexGrid1 DragMode 0 – vbManual Label1 Caption 班級信息列表 Label2( 0) Caption 添加 Label2( 1) Caption 修改 Label2( 2) Caption 刪除 Label3( 0) Caption 班級編號 Label3( 1) Caption 班級名稱 Label3( 2) Caption 導(dǎo)員姓名 Label3( 3) Caption 備注 編寫窗體代碼 Private Sub Command1_Click() If Text1(0) = Then MsgBox 班級編號不能為空! , vbOKOnly, 提示 Text1(0).SetFocus Exit Sub End If If Text1(1) = Then MsgBox 班級名稱不能為空! , vbOKOnly, 提示 Text1(1).SetFocus Exit Sub End If If Text1(2) = Then MsgBox 導(dǎo)員姓名不能為空! , vbOKOnly, 提示 Text1(2).SetFocus 19 Exit Sub End If txtSQL = select * from class_Form where class_NO=39。 amp。 Trim(Text1(0)) amp。 39。 Set mrc = ExecuteSQL(txtSQL, MsgText) If = False Then MsgBox 此班級編號已經(jīng)存在! , vbOKOnly, 警告 Text1(0).SetFocus Exit Sub End If txtSQL = select * from class_Form Set mrc = ExecuteSQL(txtSQL, MsgText) (0) = Trim(Text1(0)) (1) = Trim(Text1(1)) (2) = Trim(Text1(2)) (3) = Trim(Text1(3)) For i = 0 To 3 Text1(i) = Next MsgBox 班級信息添加成功! , vbOKOnly, 提示 ShowData End Sub Private Sub Command2_Click() For i = 0 To 3 Text1(i) = Next End Sub Private Sub Command5_Click() txtSQL = delete from class_Form where class_NO=39。 amp。 Trim(Text1(8)) amp。 39。 Set mrc = ExecuteSQL(txtSQL, MsgText) For i = 8 To 11 Text1(i) = Next MsgBox 班級已經(jīng)刪除! , vbOKOnly, 警告 ShowData End Sub Private Sub Command6_Click() For i = 8 To 11 20 Text1(i) = Next End Sub Private Sub Form_Load() = 班級信息 — 添 加 Picture1(1).Top = Picture1(0).Top Picture1(1).Left = Picture1(0).Left Picture1(2).Top = Picture1(0).Top Picture1(2).Left = Picture1(0).Left ShowData For i = 0 To 2 Label2(i).BackColor = amp。HE0E0E0 Picture1(i).Visible = False Next Label2(0).BackColor = amp。HFFFFFF Picture1(0).Visible = True End Sub Private Sub Form_Resize() 1 End Sub Private Sub Label2_Click(Index As Integer) = 班級信息 = amp。 amp。 Trim(Label2(Index).Caption) For i = 0 To 2 Label2(i).BackColor = amp。HE0E0E0 Picture1(i).Visible = False Next Label2(Index).BackColor = amp。HFFFFFF Picture1(Index).Visible = True For i = 0 To 11 Text1(i) = Next = False = False End Sub Private Sub ShowData() Dim txSQL As String Dim mrcc As txSQL = select * from class_Form Set mrcc = ExecuteSQL(txSQL, MsgText) With MSFlexGrid1 .ColWidth(0) = 1200 .ColWidth(1) = 1200 .ColWidth(2) = 1200 21 .ColWidth(3) = 6000 .TextMatrix(0, 0) = 班級編號 .TextMatrix(0, 1) = 班級名稱 .TextMatrix(0, 2) = 導(dǎo)員姓名 .TextMatrix(0, 3) = 備注信息 162。 .Rows = 1 Do While Not .Rows = .Rows + 1 For i = 0 To 1 .TextMatrix(.Rows 1, i) = (i) amp。 Next i Loop End With End Sub Private Sub MSFlexGrid1_Click() If Picture1(1).Visible = True Then Text1(4) = Trim((, 0)) Text1(5) = Trim((, 1)) Text1(6) = Trim((, 2)) Text1(7) = Trim((, 3)) = True End If If Picture1(2).Visible = True Then Text1(8) = Trim((, 0)) Text1(9) = Trim((, 1)) Text1(10) = Trim((, 2)) Text1(11) = Trim((, 3)) = True End If End Sub Private Sub Text1_Change(Index As Integer) If Index = 4 Then tSQL = select * from class_Form where class_NO=39。 amp。 Trim(Text1(Index)) amp。 39。 Set mrc = ExecuteSQL(tSQL, MsgText) If = False Th