期末考試日程管理系統(tǒng)-課程設(shè)計(jì).doc_第1頁(yè)
期末考試日程管理系統(tǒng)-課程設(shè)計(jì).doc_第2頁(yè)
期末考試日程管理系統(tǒng)-課程設(shè)計(jì).doc_第3頁(yè)
期末考試日程管理系統(tǒng)-課程設(shè)計(jì).doc_第4頁(yè)
期末考試日程管理系統(tǒng)-課程設(shè)計(jì).doc_第5頁(yè)
已閱讀5頁(yè),還剩24頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

期末考試日程管理系統(tǒng)-課程設(shè)計(jì)課程設(shè)計(jì)的目的目的是進(jìn)一步培養(yǎng)綜合應(yīng)用Visual Basic的各種編程知識(shí)和技巧進(jìn)行程序設(shè)計(jì)的能力。通過(guò)課程設(shè)計(jì),能達(dá)到具備設(shè)計(jì)功能較為復(fù)雜的Windows應(yīng)用程序的能力。同時(shí)通過(guò)課程設(shè)計(jì),培養(yǎng)自主學(xué)習(xí)和獨(dú)立創(chuàng)新的精神,是人才培養(yǎng)體系中極為重要的一環(huán)。2.設(shè)計(jì)方案論證 2.1系統(tǒng)總體設(shè)計(jì)此系統(tǒng)能查詢學(xué)生期末考試的基本信息(考試日期、時(shí)間、課程名、教室號(hào)、系名、年級(jí)、序號(hào)、考試人數(shù),教師姓名),也能重新登錄和退出本系統(tǒng),教師可以通過(guò)本系統(tǒng)查詢監(jiān)考的信息,包括樓層,教室號(hào)的,還有就是添加,保存,修改,刪除,退出等功能。系統(tǒng)功能模塊圖圖1 系統(tǒng)功能模塊圖2.2數(shù)據(jù)庫(kù)設(shè)計(jì): 在access中建立一個(gè)數(shù)據(jù)庫(kù)八個(gè)表,表分別為:安排表,登錄表,監(jiān)考教師表,教室表,課程表,日程設(shè)定表,生成表。如下: 圖2(安排表) 圖3 (登陸表) 圖4(教師監(jiān)考表)圖5(教師表) 圖6(課程表) 圖7(日程設(shè)定表)圖8 (生成表)3應(yīng)用軟件的實(shí)現(xiàn)與運(yùn)行結(jié)果 當(dāng)程序運(yùn)行之后,首先看到的界面如圖8所示,其中窗體上有帳號(hào)、密碼的輸入,并有確定和取消的選項(xiàng)按鈕 首先設(shè)計(jì)的是系統(tǒng)登錄界面、主界面、教師管理界面、然后建立了數(shù)據(jù)庫(kù),最后進(jìn)行的是數(shù)據(jù)庫(kù)的連接與程序的調(diào)試.(1)系統(tǒng)登錄 圖9 系統(tǒng)登陸界面窗體代碼如下:Private backFile As StringPrivate qs As StringPrivate buff As StringDim pnum As IntegerPrivate Sub Form_Load()addtrans App.Path 連接數(shù)據(jù)庫(kù)MsgBox 歡迎進(jìn)入六維論文(), vbInformation, 提示Shell Explorer /s , End SubPrivate Sub Text2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then 獲取按鍵,如果是回車就運(yùn)行image_click按鈕的內(nèi)容Call Image1_ClickEnd IfEnd SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenCall Image1_ClickEnd IfEnd SubPrivate Sub Image1_Click()On Error GoTo finish 防錯(cuò)代碼,防止意外而導(dǎo)致的退出Set kc1 = cnn.Execute(select * from 登陸 where 用戶名= & Text1.Text & and 密碼= & Text2.Text & )以上使用最通用的方法來(lái)查詢數(shù)據(jù)庫(kù)中是否有匹配的記錄If kc1.EOF = True Then 如果沒有記錄則說(shuō)明用戶或密碼為錯(cuò)誤的If pnum 2 Then pnum就是密碼驗(yàn)證次數(shù),當(dāng)次數(shù)超過(guò)3次,系統(tǒng)會(huì)自動(dòng)保護(hù)退出pnum = pnum + 1MsgBox 用戶名或密碼錯(cuò)誤!, vbInformation, 錯(cuò)誤次數(shù): & pnumPublic Sub addtrans(tkFileName As String)buff = String(255, 0)backFile = Date + 5Dim backfila As Stringbackfila = DateDim backfilb As Dateret = GetPrivateProfileString(OKxj, yesno, , buff, 256, c:qm.ini)If ret 0 Thenret1 = GetPrivateProfileString(Bakxj, qs, , buff, 256, c:qm.ini)Label13.Caption = buffEndElseIf Label13.Caption ks1.Fields(0) * ks2.Fields(0) ThenMsgBox 總考試人數(shù)大于教室所容納的人數(shù),請(qǐng)檢查!, vbInformation, 提示Exit SubEnd If檢查可用教師人數(shù)是否大于或等于監(jiān)考人數(shù)Set ks1 = cnn.Execute(select count(*) from 教師)Set ks2 = cnn.Execute(select sum(監(jiān)考人數(shù)) from 教室)If ks2.Fields(0) ks1.Fields(0) ThenMsgBox 教師可用人數(shù)小于教室監(jiān)考人數(shù)需求,請(qǐng)檢查!, vbInformation, 提示Exit SubEnd If檢查課程的考試數(shù)目是否超出考試安排時(shí)間Set ks1 = cnn.Execute(select count(*) from 日程設(shè)定)Set ks2 = cnn.Execute(SELECT DISTINCT 系名 from 課程)Do While Not ks2.EOFFor i = 1 To 4 Set ks3 = cnn.Execute(select count(*) from 課程 where 系名= & ks2.Fields(0) & and 年級(jí)= & i & ) If ks3.Fields(0) ks1.Fields(0) Then MsgBox ks2.Fields(0) & i & 年級(jí)的考試科目大出了日程安排數(shù)目,請(qǐng)檢查!, vbInformation, 提示 Exit Sub End IfNextks2.MoveNextLoopSet ks1 = cnn.Execute(select * from 日程設(shè)定)Set ks2 = cnn.Execute(select * from 教師)Do While Not ks2.EOFDo While Not ks1.EOF Set ks3 = cnn.Execute(insert into 安排 values( & ks2.Fields(0) & , & ks1.Fields(0) & , & ks1.Fields(1) & ,0) ks1.MoveNextLoop Set ks1 = cnn.Execute(select * from 日程設(shè)定) 因?yàn)椴捎昧薙QL語(yǔ)句方式,無(wú)法將指針指向第一位,所以必須在次讀取數(shù)據(jù)庫(kù) ks2.MoveNextLoopasPopup1.Enabled = FalseasPopup2.Enabled = FalseasPopup3.Enabled = FalseEnd SubPrivate Sub asPopup6_Click(Cancel As Boolean)PBar1.Value = 0Timer1.Interval = 100asPopup6.Enabled = FalseEnd SubPrivate Sub sc() 這里是生成的主代碼MsgBox 未授權(quán)作品,在源碼中有對(duì)此代碼的詳細(xì)思路注解,請(qǐng)參照!, vbInformation, 提示End SubPrivate Sub asPopup7_Click(Cancel As Boolean)formshow.Show 1End SubPrivate Sub asPopup8_Click(Cancel As Boolean)這里就是對(duì)已經(jīng)生成的記錄進(jìn)行清除,實(shí)現(xiàn)數(shù)據(jù)的在生成與在管理Set ks1 = cnn.Execute(delete from 監(jiān)考教師)Set ks1 = cnn.Execute(delete from 安排)Set ks1 = cnn.Execute(update 教室 set 已選=0)Set ks1 = cnn.Execute(delete from 生成)MsgBox 清除完成!, vbInformation, 提示asPopup1.Enabled = True asPopup2.Enabled = True asPopup3.Enabled = True asPopup4.Enabled = True asPopup5.Enabled = TrueasPopup6.Enabled = FalseasPopup7.Enabled = FalseasPopup8.Enabled = FalseEnd SubPrivate Sub asPopup9_Click(Cancel As Boolean)Dim fo2 As CTranslucentFormSet fo2 = New CTranslucentFormfo2.hWnd = user.hWndfo2.Alpha = 93 / 100 * 255user.Show 1End SubPrivate Sub Form_Load()PBar1.Max = 100 設(shè)定進(jìn)度條最大值為100以下是通過(guò)判斷安排表和生成表是否為空,來(lái)確定用戶是否還可以操作一些日程設(shè)定,教室管理等內(nèi)容Set ks1 = cnn.Execute(select count(*) from 安排)If ks1.Fields(0) 0 Then asPopup1.Enabled = False asPopup2.Enabled = False asPopup3.Enabled = False asPopup4.Enabled = False asPopup5.Enabled = False Set ks2 = cnn.Execute(select count(*) from 生成) If ks2.Fields(0) 0 Then asPopup6.Enabled = False End IfPrivate Sub Timer1_Timer()If PBar1.Value 95 ThenLabel1.Visible = TrueLabel1.Caption = 正在進(jìn)行生成.PBar1.Value = PBar1.Value + 5ElseTimer1.Interval = 0Call scEnd IfEnd Sub(3)查詢窗體:當(dāng)我們進(jìn)入查詢窗體時(shí) 會(huì)進(jìn)入如圖10所示的界面,其中有開始執(zhí)行按鈕,輸入自己想要查詢的對(duì)象信息,即可達(dá)到查詢效果代碼如下:圖11 查詢窗體界面Dim n As IntegerPrivate Sub Form_Load()Grid1.SetRegisterInformation CNwinndy, WvyY-nonvk-unty-Zbl_e-hms 進(jìn)行注冊(cè)Grid2.SetRegisterInformation CNwinndy, WvyY-nonvk-unty-Zbl_e-hms 進(jìn)行注冊(cè)With Grid1 以下是對(duì)表格控件進(jìn)行一些顏色和字體等設(shè)置 .AllowUserResizing = True .DisplayFocusRect = False .ExtendLastCol = True .Appearance = Flat .FixedRowColStyle = Flat .ScrollBarStyle = Flat .DefaultFont.Name = Tahoma .DefaultFont.SIZE = 8 .BackColorFixed = RGB(84, 201, 134) RGB(90, 158, 214) .BackColorFixedSel = RGB(84, 201, 134) RGB(110, 180, 230) .BackColorBkg = RGB(84, 201, 134) RGB(90, 158, 214) .BackColorScrollBar = RGB(231, 235, 247) .BackColor1 = RGB(231, 235, 247) .BackColor2 = RGB(239, 243, 255) .GridColor = RGB(148, 190, 231) .Column(0).Width = 0End WithWith Grid2 .DefaultFont.Name = Tahoma .DefaultFont.SIZE = 8 .BackColorFixed = RGB(90, 158, 214).BackColorFixedSel = RGB(110, 180, 230) .BackColorBkg = RGB(90, 158, 214) .BackColorScrollBar = RGB(231, 235, 247) .BackColor1 = RGB(231, 235, 247) .BackColor2 = RGB(239, 243, 255) .GridColor = RGB(148, 190, 231) .Column(0).Width = 0End WithMe.BackColor = RGB(84, 201, 134)以下cellcombobox是控件grid 的一個(gè)屬性,即是在表格單元格可以出現(xiàn)下拉框,下拉框中就是用戶所需的快捷內(nèi)容Grid1.Column(1).CellType = cellComboBoxGrid1.Column(2).CellType = cellComboBoxGrid1.Column(3).CellType = cellComboBoxGrid1.Cell(0, 1).Text = 查詢模式 將表格內(nèi)添入固定內(nèi)容Grid1.Cell(0, 2).Text = 查詢段Grid1.Cell(0, 3).Text = 條件Grid1.Cell(0, 4).Text = 關(guān)鍵字Grid1.Cell(0, 5).Text = 附加條件Grid1.ComboBox(1).AddItem 精確查詢 這里是類似combo框的操作,也是把內(nèi)容添入combo控件的記錄集Grid1.ComboBox(1).AddItem 模糊查詢Grid1.ComboBox(2).AddItem 系名Grid1.ComboBox(2).AddItem 年級(jí)Grid1.ComboBox(2).AddItem 課程名Grid1.ComboBox(2).AddItem 教室號(hào)Grid1.ComboBox(2).AddItem 考試日期Grid1.ComboBox(2).AddItem 時(shí)間Grid1.ComboBox(2).AddItem 樓層Grid1.ComboBox(2).AddItem 教師Grid1.ComboBox(2).AddItem 教師監(jiān)考次數(shù)Grid1.Cell(1, 1).Text = 精確查詢End SubPrivate Sub Grid1_RowColChange(ByVal Row As Long, ByVal Col As Long)If Grid1.Cell(1, 1).Text Then期末考試日程管理系統(tǒng)If Grid1.Cell(1, 1).Text = 精確查詢 ThenGrid1.ComboBox(3).Clear 以下清除表格中combo集中的內(nèi)容,并加入以下內(nèi)容Grid1.ComboBox(3).AddItem =Grid1.ComboBox(3).AddItem Grid1.ComboBox(3).AddItem =Grid1.ComboBox(3).AddItem =Grid1.ComboBox(3).AddItem End IfEnd SubDim moshi As Integer 這是主要判斷選擇模式(精確還模糊)Select Case Grid1.Cell(1, 2).Text 以下主要通過(guò)多項(xiàng)選擇來(lái)決定SQL語(yǔ)句的組織方法Case 年級(jí), 課程名, 考試日期, 時(shí)間, 系名 此處幾個(gè)都屬通用的SQL語(yǔ)句,所以可以放在一起If moshi = 0 Then 通過(guò)已確定的模糊查詢還是精確查詢來(lái)決定語(yǔ)句的組成 strsql = select * from 生成 where & Grid1.Cell(1, 2).Text & Grid1.Cell(1, 3).Text & & Grid1.Cell(1, 4).Text & Else strsql = select * from 生成 where & Grid1.Cell(1, 2).Text & & Grid1.Cell(1, 3).Text & % & Grid1.Cell(1, 4).Text & %End If numberkc = 6 設(shè)置字段長(zhǎng)和表格的列數(shù) Grid2.Cols = numberkc + 1Case 教室號(hào) If moshi = 0 Then strsql = select * from 生成 where & Grid1.Cell(1, 2).Text & like % & Grid1.Cell(1, 4).Text & % 關(guān)于教室語(yǔ)句中用到%號(hào),因?yàn)槊總€(gè)系并不是一個(gè)考場(chǎng),所以在教定中含有多個(gè)教室,所以需要%來(lái)提取Else strsql = select * from 生成 where & Grid1.Cell(1, 2).Text & & Grid1.Cell(1, 3).Text & % & Grid1.Cell(1, 4).Text & %End If numberkc = 6 Grid2.Cols = numberkc + 1Case 教師strsql = select 監(jiān)考教師.教室號(hào),教師姓名,日期,監(jiān)考教師.時(shí)間,課程名,系名,年級(jí) from 監(jiān)考教師,生成 where 考試日期=日期 and 監(jiān)考教師.時(shí)間=生成.時(shí)間 and 教師姓名 like % & Grid1.Cell(1, 4).Text & %numberkc = 7 Grid2.Cols = numberkc + 1 Case 樓層 If moshi = 0 Then strsql = select 考試日期,時(shí)間,課程名,生成.教室號(hào),系名,年級(jí),樓層 from 教室,生成 where 樓層= & Grid1.Cell(1, 4).Text & Else strsql = select 考試日期,時(shí)間,課程名,生成.教室號(hào),系名,年級(jí),樓層 from 教室,生成 where 樓層 like % & Grid1.Cell(1, 4).Text & % End If numberkc = 7 Grid2.Cols = numberkc + 1End Select If Grid1.Cell(1, 5).Text Then 這是確定是否有附加條件,有則將其并入語(yǔ)句中一起執(zhí)行 strsql = strsql & & Grid1.Cell(1, 5).Text End IfGrid2.Rows = 1Set ks1 = cnn.Execute(strsql) 這里執(zhí)行已組織好的語(yǔ)句For i = 1 To numberkc 通來(lái)字段的長(zhǎng)度,將各字段應(yīng)有的名稱寫入表格Grid2.Cell(0, i).Text = ks1.Fields(i - 1).NameNextDo While Not ks1.EOF 以下是將查詢到的內(nèi)容依次寫入表格Grid2.Rows = Grid2.Rows + 1For i = 1 To numberkcGrid2.Cell(Grid2.Rows - 1, i).Text = ks1.Fields(i - 1)Nextks1.MoveNextLoopLabel1.Caption = 符合條件的記錄數(shù): & Grid2.Rows - 1 & 條!Exit Subfinish:MsgBox Err.DescriptionEnd Sub(4)查看窗體進(jìn)入查詢窗體界面,如圖11所示,上面含有打印的選項(xiàng)按鈕。選中打印按鈕,即可實(shí)現(xiàn)對(duì)目標(biāo)的打印圖12 查看窗體界面Dim m, n, X, Y, len1 As IntegerDim str1, sstr1 As StringPrivate Sub Form_Load()Grid1.SetRegisterInformation CNwinndy, WvyY-nonvk-unty-Zbl_e-hms 進(jìn)行注冊(cè)With Grid1 以下是對(duì)表格控件進(jìn)行一些顏色和字體等設(shè)置 .AllowUserResizing = True.FixedRowColStyle = Flat .ScrollBarStyle = Flat .DefaultFont.Name = Tahoma .DefaultFont.SIZE = 10 .BackColorFixed = RGB(84, 201, 134) RGB(90, 158, 214) .BackColorFixedSel = RGB(84, 201, 134) RGB(110, 180, 230) .BackColorBkg = RGB(84, 201, 134) RGB(90, 158, 214) .BackColorScrollBar = RGB(231, 235, 247) .BackColor1 = RGB(231, 235, 247) .BackColor2 = RGB(239, 243, 255) .GridColor = RGB(148, 190, 231) .Column(0).Width = 120 .RowHeight(0) = 0 .ReadOnly = TrueEnd WithMe.BackColor = RGB(84, 201, 134)Generalview 在窗體啟動(dòng)時(shí)自動(dòng)調(diào)用過(guò)程End SubSet ks1 = cnn.Execute(select * from 日程設(shè)定 order by 序號(hào) asc)通過(guò)SQL的查詢語(yǔ)句將日程設(shè)定的日期和時(shí)間寫入表格For i = 1 To Grid1.Cols - 1Grid1.Column(i).Width = 120Grid1.Cell(0, i).Text = ks1.Fields(0) & vbCrLf & ks1.Fields(1)ks1.MoveNextNextm = 1 變量初始化n = 0X = 1Set ks2 = cnn.Execute(SELECT DISTINCT 系名 from 課程)Do While Not ks2.EOFFor i = 1 To 4 通過(guò)固定的1-4年級(jí)和系名來(lái)確定可以存在的年級(jí)Set ks3 = cnn.Execute(select count(*) from 課程 where 系名= & ks2.Fields(0) & and 年級(jí)= & i & )If ks3.Fields(0) 0 ThenGrid1.Rows = Grid1.Rows + 1Grid1.RowHeight(Grid1.Rows - 1) = 120Grid1.Cell(Grid1.Rows - 1, 0).Text = ks2.Fields(0) & vbCrLf & i & 年級(jí)Set ks3 = cnn.Execute(select * from 生成 where 系名= & ks2.Fields(0) & and 年級(jí)= & i & order by序號(hào) asc)這里開始查詢對(duì)應(yīng)班級(jí)的考試安排情況 For n = 1 To len1 由于每個(gè)系并不一定就是一個(gè)考場(chǎng)教室,所以在用逗號(hào)分開的各教室號(hào)在次區(qū)別開來(lái) If Mid(ks3.Fields(3), n, 1) = , Then str1 = Mid(ks3.Fields(3), m, Y - 1) m = n + 1 Y = 0 查找并合并對(duì)應(yīng)的監(jiān)考教師并寫入表格Set ks4 = cnn.Execute(select * from 監(jiān)考教師 where 日期= & ks3.Fields(0) & and 時(shí)間= & ks3.Fields(1) & and 教室號(hào)= & str1 & ) sstr1 = sstr1 & str1 & ( & ks4.Fields(1) & ), End If Y = Y + 1 Next str1 = Mid(ks3.Fields(3), m, Y - 1) m = n + 1 Y = 0 Set ks4 = cnn.Execute(select * from 監(jiān)考教師 where 日期= & ks3.Fields(0) & and 時(shí)間= & ks3.Fields(1) & and 教室號(hào)= & str1 & ) sstr1 = sstr1 & str1 & ( & ks4.Fields(1) & ) Grid1.Cell(Grid1.Rows - 1, j).Text = ks3.Fields(2) & vbCrLf & 教室: & ks3.Fields(3) & vbCrLf & 監(jiān)考: & sstr1 sstr1 = ks3.MoveNextLoopEnd IfNextks2.MoveNextLoopGrid1.Range(0, 0, Grid1.Rows - 1, Grid1.Cols - 1).WrapText = TrueExit Subfinish:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Resize()If Me.WindowState 1 Then Grid1.Left = (Me.Width - Grid1.Width) / 2 Grid1.Width = (Me.Width / 2) + Grid1.Left Grid1.Left = (Me.Width - Grid1.Width) / 2 Grid1.Top = 600 Grid1.Height = Me.Height - Grid1.Top - 600 XPButton1.Left = (Me.Width - XPButton1.Width) / 2End IfEnd SubPrivate Sub Grid1_AfterReorderColumn(ByVal OriginalPosition As Long, ByVal NewPosition As Long)End SubPrivate Sub print_Click()On Error GoTo finish 設(shè)置打印區(qū)域 Grid1.PageSetup.PrintFixedRow = True 設(shè)定是否允許打印第0行 Grid1.PageSetup.PrintFixedColumn = True 是否打印第0列 Grid1.PageSetup.PrintRows = Grid1.Rows - 1 需要打印的總行數(shù) Grid1.PageSetup.PrintColumns = Grid1.Cols - 1 需要打印的總列數(shù) Grid1.PageSetup.PrintGridlines = True 是否顯示中間的分隔線,即表格線 Grid1.AutoRedraw = True Grid1.PageSetup.Orientation = cellLandscape 采用橫幅打印還是豎行打印 Grid1.PrintDialog Grid1.PrintPreview 打印預(yù)覽 Grid1.Refresh Exit Subfinish: MsgBox Err.DescriptionEnd SubPrivate Sub XPButton1_Click()Call print_ClickEnd Sub(5)課程管理窗體當(dāng)我們進(jìn)入課程管理窗體時(shí),如圖12所示,其中窗體的右部有菜單選項(xiàng),分別有增加,保存,刪除和退出,點(diǎn)擊任意按鈕,即可進(jìn)行相關(guān)的操作期末考試日程管理系統(tǒng)圖13 管理系統(tǒng)界面Dim i As IntegerPrivate Declare Function GetKeyState Lib user32 _ (ByVal nVirtKey As Long) As IntegerDim gcolor1, gcolor2 As StringDim m, n As IntegerPrivate Sub Form_Load()Grid1.SetRegisterInformation CNwinndy, WvyY-nonvk-unty-Zbl_e-hms 進(jìn)行注冊(cè)With Grid1 .AllowUserResizing = True .DisplayFocusRect = False .ExtendLastCol = True .Appearance = Flat .FixedRowColStyle = Flat .ScrollBarStyle = Flat .BackColorScrollBar = RGB(231, 235, 247) .BackColor1 = RGB(231, 235, 247) .BackColor2 = RGB(239, 243, 255) .GridColor = RGB(148, 190, 231).Column(0).Width = 0 .Column(1).Width = 100 .Column(2).Width = 40 .Column(3).Width = 100 .Column(4).Width = 40End WithMe.BackColor = RGB(84, 201, 134)Private Sub callmain()kssave = Falseksedit = Trueksdel = TrueSet ks1 = cnn.Execute(select * from & kstable) Grid1.Rows = 1 清除所有記錄i = 4Grid1.Cols = i + 1 必須+1,因?yàn)閷?shí)際上為4行,但第一行是隱藏的For i = 0 To i - 1 顯示數(shù)據(jù)的字段名Grid1.Cell(0, i + 1).Text = ks1.Fields(i).Name 讀取表中的各字段名Nextn = ii = 1Do While Not ks1.EOF Grid1.Rows = Grid1.Rows + 1 For j = 1 To n 設(shè)定讀取列 If IsNull(ks1.Fields(j - 1) Then 空值的處理 Grid1.Cell(i, j).Text = Else Grid1.Cell(i, j).Text = ks1.Fields(j - 1) End If Next i = i + 1 ks1.MoveNext 讀取下一記錄LoopGrid1.Column(1).Locked = TrueEnd SubPrivate Sub Grid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 2 ThenPopupMenu czEnd IfEnd SubPrivate Sub Grid1_RowColChange(ByVal Row As Long, ByVal Col As Long)hang = RowEnd SubPrivate Sub Grid1_Validate(Cancel As Boolean) 設(shè)定TAB鍵切換Dim nActiveRow As Long, nActiveCol As Long Const VK_TAB = 9 If GetKeyState(VK_TAB) 0 Then nActiveRow = Grid1.ActiveCell.Row nActiveCol = Grid1.ActiveCell.Col If nActiveCol Grid1.Cols - 1 Then Grid1.Range(nActiveRow, nActiveCol + 1, _ nActiveRow, nActiveCol + 1).Selected End If Cancel = True End If End SubPrivate Sub renovate_Click()Call callmainEnd SubPrivate Sub XPButton1_Click()kssave = TrueSet ks1 = cnn.Execute(select * from & kstable)Grid1.Rows = 1 清除所有記錄Grid1.Rows = 21 默認(rèn)為2行Grid1.Column(1).CellType = cellComboBoxGrid1.Column(2).CellType = cellComboBoxGrid1.ComboBox(1).ClearGrid1.ComboBox(2).ClearSet ks2 = cnn.Execute(SELECT DISTINCT 系名 from 課程)Do While Not ks2.EOFGrid1.ComboBox(1).AddItem ks2.Fields(0)ks2.MoveNextLoopFor i = 1 To 4Grid1.ComboBox(2).AddItem iNextFor i = 0 To 3 顯示數(shù)據(jù)的字段名Grid1.Cell(0, i + 1).Text = ks1.Fields(i).Name 讀取表中的各字段名NextGrid1.Column(1).Locked = FalseGrid1.Cell(1, 1).SetFocusXPButton2.Default = TrueEnd SubEnd IfIf m 0 And n 0 ThenGrid1.Range(m, 1, m, 4).BackColor = gcolor1Grid1.Range(n, 1, n, 4).BackColor = gcolor2End If保存,另一個(gè)還沒保存就出現(xiàn)了問題。-For i = 1 To Grid1.Rows - 1For j = i + 1 To Grid1.Rows - 1 If Grid1.Cell(i, 1).Text Then If Grid1.Cell(i, 1).Text = Grid1.Cell(j, 1).Text And Grid1.Cell(i, 2).Text = Grid1.Cell(j, 2).Text And Grid1.Cell(i, 3).Text = Grid1.Cell(j, 3).Text Then MsgBox 第 & i & 行與 & j & 行的數(shù)據(jù)出現(xiàn)重復(fù),請(qǐng)修改!, vbInformation, 重復(fù)錯(cuò)誤 m = i n = j gcolor1 = Grid1.Cell(m, 1).BackColor gcolor2 = Grid1

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論