vb视频教程下载
Dim kj1,kj2,kj3,kj4,kj5,kj6
Dim QR
Dim MSFlexGrid1'对应表格控件名称
Dim LocalBeginTime,LocalEndTime,riqi
Dim oRs,oRs1,n,n1,i,z,s1,s11,oCom,oCom1,strcn,conn,pj
Dim zxy1
'查询当天全部数据,除了控件名要注意修改外,以上其他为标准
Set MSFlexGrid1 = ScreenItems("A1")'对应表格控件名称
riqi = Now
LocalBeginTime = Year(riqi) & "-" & Month(riqi) & "-" & Day(riqi) & " " & "00:00:00" LocalEndTime = Year(riqi) & "-" & Month(riqi) & "-" & Day(riqi) & " " & "23:59:59"
MsgBox "1......"
s1 = "SELECT DT,Name,B1,B2,B3,B4,B5 FROM biao1 WHERE DT BETWEEN '" & LocalBeginTime & "' and'" & LocalEndTime & "'ORDER BY DT"
'S1后面的内容要对应数据库中列的内容,后面的DT与前面的DT要名称一致,biao要对应数据库列表名
称dbo.后面的名称
strcn ="Provider=SQLOLEDB.1;Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=Project_1;Data Source=.\wincc"
Set conn=CreateObject("tion")
conn.CursorLocation = 3
conn.Open
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command") MsgBox "2......"
oCom.CommandType = 1
MsgBox "3......"
Set oCom.ActiveConnection = conn
MsgBox "4......"
oCom.CommandText = s1
MsgBox "5......"
Set oRs = oCom.Execute
n = oRs.RecordCount '获得检索到的总行数
MsgBox "6......"
'定义在线表格属性
MSFlexGrid1.Clear
MSFlexGrid1.Rows = oRs.RecordCount+2 MSFlexGrid1.ColWidth(0)=700 '第一列宽度设置MSFlexGrid1.ColWidth(1)=3300
MSFlexGrid1.ColWidth(2)=1000
MSFlexGrid1.ColWidth(3)=1500
MSFlexGrid1.ColWidth(4)=1500
MSFlexGrid1.ColWidth(5)=1500
MSFlexGrid1.ColWidth(6)=1500
MSFlexGrid1.ColWidth(7)=1500
MSFlexGrid1.RowHeight(0)=600
MSFlexGrid1.RowHeight(1)=400
MSFlexGrid1.Row = 0
For z = 0 To 7'根据上面的列数改变MSFlexGrid1.CellFontSize = 12
MSFlexGrid1.Col = z
MSFlexGrid1.Text = "统计表"
Next
MSFlexGrid1.MergeCells = 4'相同内容合并单元格MSFlexGrid1.MergeRow(0) = True '合并单元格
MSFlexGrid1.Row = 1
For z = 0 To 7 '根据上面的列数改变
MSFlexGrid1.Col = z

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。