## 該窗體涉及到msflexgrid1控制項與及excle表的匯出,在這一步中所遇到的問題如下:
1)下標越界381:下標越界 原因:是在myflexgrid中溢位問題:
該窗體的思路,沒有用流程圖,手動大概寫了一下,具體如下:
判斷卡號是否為空---為空,提示----不為空,連線student資料庫----存在,連線line表----myflexgrid控制項顯示資訊----對execle定義
注意:還有excle的引用
定義excle部分
dim xlbook as excel.workbook '宣告工作薄物件
dim xlsheet as excel.worksheet '宣告工作表單
dim i as integer
dim j as interger
if msflexgrid1.text = "" then
msgbox"沒有記錄可以匯出",48,"提示"
exit sub
else
set xlsheet = xlbook.worksheets(1) '建立新的工作表單
'填入資料
for i = 0 to msflexgrid.rows - 1 '行迴圈
for j = o to msflexgrid.cols - 1
xlsheet.cells(i+1, j+1) = msflexgrid1.textmatrix(i , j )
next i
next j
end if
## 查詢部分
txtsql = " select * from line_info where cardno = 』 " & txtcardno.text & " 』 "
set mrc = executesql(txtsql, msgtext)
with msglexgrid1
.row = 1
.cellalignment = 4
.textmatrix(0,0) = 「卡號」
.textmatrix(0,1)= 「姓名」
.textmatrix(0, 2) = 「上機日期」
.textmatrix(0, 3) = 「上機時間」
.textmatrix(0, 4) = 「下機日期」
.textmatrix(0, 5) = 「下機時間」
.textmatrix(0, 6) = 「消費金額」
.textmatrix(0, 7) = 「餘額」
.textmatrix(0, 8) = 「備註」
'判斷是否是否移動到資料物件的最後一條
do while not mrc.eof
.rows = .rows + 1
.cellalignment = 4
.textmatrix(rows - 1, 0 ) = mrc.fields(1)
.textmatrix(rows - 1,1) = mrc.fields(3)
.textmatrix(rows - 1, 2) = mrc.fields(6)
.textmatrix(rows - 1, 3) = mrc.fields(7)
.textmatrix(rows - 1, 4) = mrc.fields(8)
.textmatrix(rows - 1, 5) = mrc.fields(9)
.textmatrix(rows - 1, 6) = mrc.fields(11)
.textmatrix(rows - 1, 7) = mrc.fields(12)
.textmatrix(rows - 1, 8) = mrc.fields(13)
mrc.movenext
loop
end with
mrc.close
不怕不知道,就怕不知道。
學生檢視上機記錄(MSFlexGrid載入資料 )
先放上 private sub cmdinquiry click 判空if txtcardno then msgbox 卡號不能為空 vbokonly vbexclamation,警告 txtcardno.setfocus exit sub else 鏈結學生表 txtsql select card...
機房收費系統 上機記錄查詢
private sub cmdcha click 清空表內容,保留表頭 msflexgrid1.rows 2 表連線 strsql3 select from line info where cardno trim txtkahao.text line?set mrc3 executesql strs...
機房收費系統 上機
檢查乙個卡號能否使用,需要檢查以下幾點 只有這幾點同時滿足,此卡才能正常上機。1 當然不用多說,不輸入卡號當然不能使用。2 與要求的最小餘額進行比較,小於最小餘額則禁止上機使用 3 此卡沒用註冊,登錄檔中沒有這條記錄 4 次卡正在處於上機狀態,提示正在上機,一卡禁止重複上機使用 下面的這段 僅為借鑑...