機械室料金システム総括——フォームコードフレームワーク
一、判断
1.データベースは不要
1).空白文字かどうか
2).数値かどうか
3).前後が同じかどうか
汎用フォーマット:
TesttxtではIsNumeric(数字かどうかの判断)に書き換えたり、条件は
txtIdentifyPWD.Text <>txtPWD.Text、みんなが傍通すればいいです.
2.データベースが必要
1).カード番号が同じかどうか
2).カード番号は存在しますか?
3).記録の有無の判断
二、SQL文の増加、削除、変更、検索
増加:
例1:
例2:
削除:
例1:
変更:
例1:
例2:
検索:
2つのDTPickerコントロールで構成される期間クエリー:
データベース・テーブルのレコード数を計算するクエリー:
1つのテーブルの合計を求めるクエリ:
三、表示方式
1.text
textのcaptionプロパティ
2.flexgrid
システムにはflexgridテーブルの内容をループで表示することが多い.
3.excelテーブルに出力
4.list
List1.AddItem「チャージ教師:」&MyUserID
5.印刷プレビュー
Report.PrintPreview (True)
6.レポート
1.データベースは不要
1).空白文字かどうか
2).数値かどうか
3).前後が同じかどうか
汎用フォーマット:
If Not Testtxt(txtUserID.Text) Then
MsgBox " !", vbOKOnly +vbExclamation, " "
txtUserID.SetFocus
Exit Sub
End If
TesttxtではIsNumeric(数字かどうかの判断)に書き換えたり、条件は
txtIdentifyPWD.Text <>txtPWD.Text、みんなが傍通すればいいです.
2.データベースが必要
1).カード番号が同じかどうか
2).カード番号は存在しますか?
3).記録の有無の判断
二、SQL文の増加、削除、変更、検索
増加:
例1:
txtSQL = "select * from User_Info whereLevel='" & Trim(ComboHead.Text) & "'"
set mrc=ExecuteSQL(txtSQL,MsgText)
mrc.addnew
例2:
txtSQL = "insert into checkday_Info values('" & ReMainCash & "','" &ReChargeCash & "','" & ConsumeCash & "','"& Cancel Cash & "','" & AllCash & "','" &Mydate & "')"
Set mrc = ExecuteSQL(txtSQL, MsgText)
削除:
例1:
txtSQL = "delete from User_Info where UserID='" & Trim(DelUser) & "'"
Set mrc = ExecuteSQL(DelSQL, MsgText)
変更:
例1:
txtSQL = "select * from User_Info whereLevel='" & Trim(ComboHead.Text) & "'"
set mrc=ExecuteSQL(txtSQL,MsgText)
mrc.addnew
例2:
txtSQL="update student_Info set cash="& Balance &" where cardno='"& Trim(cardno) &"'"
set mrc=ExecuteSQL(txtSQL,MsgText)
検索:
2つのDTPickerコントロールで構成される期間クエリー:
txtSQL= "select * from CancelCard_Info where Date between '" &CStr(DTPicker1.Value) & "' and'" & CStr(DTPicker2.Value)& "'"
データベース・テーブルのレコード数を計算するクエリー:
txtSQL= "select Count(*) from OnLine_Info"
1つのテーブルの合計を求めるクエリ:
txtSQL= "select sum(addmoney) from Recharge_Info where UserID='" &Trim(cmbOperatorName) & "'and status=' '"
三、表示方式
1.text
textのcaptionプロパティ
2.flexgrid
システムにはflexgridテーブルの内容をループで表示することが多い.
With myflexgrid
.Font = " "
.Font.Size = "16"
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = " "
.TextMatrix(0, 1) = " "
.TextMatrix(0, 2) = " "
.TextMatrix(0, 3) = " "
.TextMatrix(0, 4) = " "
.TextMatrix(0, 5) = " "
While mrc.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = mrc.Fields(2)
.TextMatrix(.Rows - 1, 1) = mrc.Fields(3)
.TextMatrix(.Rows - 1, 2) = mrc.Fields(4)
.TextMatrix(.Rows - 1, 3) = mrc.Fields(5)
.TextMatrix(.Rows - 1, 4) = mrc.Fields(6)
.TextMatrix(.Rows - 1, 5) = mrc.Fields(7)
mrc.MoveNext
Wend
3.excelテーブルに出力
Dim i As Integer
Dim j As Integer
' ,
On Error Resume Next
If myflexGrid.TextMatrix(1, 0) = "" Then
MsgBox " ", vbInformation, " "
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.application")' excel
Dim exbooks As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add'
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = True
With excelApp.ActiveSheet' excel
For i = 1 To myflexGrid.Rows
For j = 1 To myflexGrid.Cols
.Cells(i, j).Value = "" & Format$(myflexGrid.TextMatrix(i - 1, j - 1))
Next j
Next i
End With
Set exsheet = Nothing
Set exbook = Nothing
Set excelApp = Nothing
4.list
List1.AddItem「チャージ教師:」&MyUserID
5.印刷プレビュー
Report.PrintPreview (True)
6.レポート