一、判断
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)
查: 通过两个DTPicker控件 构成的时间段查询:
- txtSQL= "select * from CancelCard_Info where Date between '" &CStr(DTPicker1.Value) & "' and'" & CStr(DTPicker2.Value)& "'"
计算一个数据库表中记录数量的查询:
- txtSQL= "select Count(*) from OnLine_Info"
对一个表中的某一项求和的查询:
- 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.报表
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。