有一个问题,盼大家能给予最后的解决,我简单的测试源程序如下.   
  '#######################################################################   
  Dim   conn   As   ADODB.Connection   
  Dim   rst   As   ADODB.Recordset   
  Dim   Cpage   As   Integer                                                                   '记录当前为第几页.   
  Dim   PageSum   As   Integer   
  Private   Sub   cmdFirst_Click()   
  Call   GridShow(1)   
  Cpage   =   1   
  End   Sub   
  '到某一页.   
  Private   Sub   cmdGo_Click()   
  If   Not   IsNumeric(Trim(txtGoPage))   Then   
      MsgBox   "您必须输入一个正确的数字型的数据!",   vbOKOnly   +   vbExclamation,   "警告!"   
      Exit   Sub   
  Else   
      If   Int(Trim(txtGoPage))   <   1   Or   Int(Trim(txtGoPage))   >   PageSum   Then   
          MsgBox   "您必须输入一个从1到"   &   PageSum   &   "的数字!",   vbOKOnly   +   vbExclamation,   "警告!"   
          Exit   Sub   
      Else   
          Call   GridShow(Int(Trim(txtGoPage)))   
          Cpage   =   Int(Trim(txtGoPage))   
      End   If   
  End   If   
  End   Sub   
    
  Private   Sub   cmdLast_Click()   
  Cpage   =   PageSum   
  Call   GridShow(Cpage)   
  End   Sub   
    
  Private   Sub   cmdNext_Click()   
  Cpage   =   Cpage   +   1   
  Call   GridShow(Cpage)   
  End   Sub   
    
  Private   Sub   cmdPrv_Click()   
    
  If   Cpage   <=   1   Then   
      MsgBox   "已经是第一页了!"   
      Exit   Sub   
  End   If   
  Cpage   =   Cpage   -   1   
  Call   GridShow(Cpage)   
  End   Sub   
    
  Private   Sub   Form_Load()   
  Cpage   =   1   
  Set   conn   =   New   ADODB.Connection   
  Set   rst   =   New   ADODB.Recordset   
  conn.Open   "Provider=SQLOLEDB.1;Persist   Security   Info=False;User   ID=sa;pwd=1111;Initial   Catalog=hospital;Data   Source=HANSBLUE"   
  Call   GridShow(Cpage)   
    
  End   Sub   
    
  '*********分页显示的函数***********   
  Private   Function   GridShow(pageno   As   Integer)   
  On   Error   Resume   Next   
  rst.Open   "SELECT   *   FROM   日志表",   conn,   adOpenKeyset,   adLockOptimistic   
    
  '以下注释掉的部分得出的pagesum是正确的.   
  '---------------------------------   
  'Debug.Print   rst.RecordCount   
  'While   Not   rst.EOF   
  'PageSum   =   PageSum   +   1   
  'rst.MoveNext   
  'Wend   
  'rst.MoveFirst   
  'PageSum   =   CInt(PageSum   /   50)   +   1   
  '--------------------------------------   
  conn.CursorLocation   =   adUseClient   
  rst.PageSize   =   50   
  rst.AbsolutePage   =   pageno   
  PageSum   =   rst.PageCount   
  '改成以下的代码也没用,第一次启动窗口pagesum的值仍为-1   
  '----------------------------------------------   
  'PageSum   =   Int(rst.RecordCount   /   50)   +   1   
  'Debug.Print   PageSum,   rst.RecordCount   
  '------------------------------------------   
  With   MSHFlexGrid1   
  .Clear   
  .Rows   =   rst.PageSize   +   2   
  .Cols   =   5   
        For   i   =   1   To   rst.PageSize   
            If   rst.EOF   Then   
                If   Cpage   =   1   Or   Cpage   >   PageSum   Then   
                      MsgBox   "没有可供显示的记录!请确认!"   
                      Exit   Function   
                End   If   
            End   If   
            .TextMatrix(i,   0)   =   ""   &   CStr((pageno   -   1)   *   50   +   i)           '第一行显示的为序号   
            .TextMatrix(i,   1)   =   ""   &   rst.Fields(0)   
            .TextMatrix(i,   2)   =   ""   &   rst.Fields(1)   
            .TextMatrix(i,   3)   =   ""   &   rst.Fields(2)   
            .TextMatrix(i,   4)   =   ""   &   rst.Fields(3)   
            rst.MoveNext   
        Next   i   
        rst.Close   
        txtShow   =   "共"   &   PageSum   &   "页"                               'txtShow文本框用来显示共有多少页   
  End   With   
  End   Function   
'一开始运行的时候,它会显示第一页,但是如果在文本框内输入1,则转到第二页,为什么呢