| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 246 人关注过本帖
标题:数据在窗体中的翻页
只看楼主 加入收藏
keker
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-11-3
收藏
 问题点数:0 回复次数:0 
数据在窗体中的翻页

用mshflexgrid控件实现数据库翻页
========================
打开vb6.0
在窗体中加入2个command控件,1个mshflexgrid控件
代码:
-----------------------------
Dim intpage As Integer

Private Sub Command1_Click()
intpage = intpage - 1
page intpage
End Sub

Private Sub Command2_Click()

intpage = intpage + 1
page intpage
End Sub

Sub page(intpagecount As Integer)
On Error Resume Next
Dim cn As New ADODB.Connection
Dim cm As New ADODB.Command
Dim rs As New ADODB.Recordset
MSHFlexGrid1.Clear
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\Students.mdb"
cn.Open
cm.ActiveConnection = cn
rs.CursorLocation = adUseClient
rs.Open "select * from 新生入学信息表 ", cn, adOpenDynamic, adLockBatchOptimistic
rs.PageSize = 10
If intpagecount > rs.PageCount Then
intpagecount = rs.PageCount
End If
If intpagecount < 1 Then
intpagecount = 1
End If
rs.AbsolutePage = intpagecount

'MsgBox rs.Fields.Count
With MSHFlexGrid1
.Cols = rs.Fields.Count
.Rows = 10
For i = 0 To 9
For j = 0 To rs.Fields.Count - 1
.TextMatrix(i, j) = rs.Fields(j)
Next
rs.MoveNext
Next
End With
End Sub

Private Sub Form_Load()
Command2.Caption = "下一页"
Command1.Caption = "上一页"
page 1
End Sub

搜索更多相关主题的帖子: 窗体 数据 
2007-11-03 22:50
快速回复:数据在窗体中的翻页
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029489 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved