标题:求问这个程序该如何实现查询功能
只看楼主
kenan136
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-5-15
结帖率:100%
已结贴  问题点数:20 回复次数:3 
求问这个程序该如何实现查询功能
程序如下:

Private Sub Command1_Click()    '窗体3
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\我的文档\毕业设计\我的毕业设计\VB\测试\数据.mdb;Persist Security Info=False"
rs.CursorType = adOpenKeyset
rs.LockType = adLockBatchOptimistic
rs.Open "select * from GPS数据", conn
Call GridshowofADO(rs)
End Sub


Sub GridshowofADO(rs As ADODB.Recordset)      '全部显示
If Not rs.Fields(0) = 0 Then
  MSFlexGrid1.TextMatrix(0, 0) = "时间"
  MSFlexGrid1.TextMatrix(0, 1) = "北纬"
  MSFlexGrid1.TextMatrix(0, 2) = "东经"
  MSFlexGrid1.TextMatrix(0, 3) = "处理后的时间"
  MSFlexGrid1.TextMatrix(0, 4) = "处理后的北纬"
  MSFlexGrid1.TextMatrix(0, 5) = "处理后的东经"
  MSFlexGrid1.TextMatrix(0, 6) = "所在城市"
  MSFlexGrid1.ColWidth(0) = 700
  MSFlexGrid1.ColWidth(1) = 1000
  MSFlexGrid1.ColWidth(2) = 1000
  MSFlexGrid1.ColWidth(3) = 1250
  MSFlexGrid1.ColWidth(4) = 1400
  MSFlexGrid1.ColWidth(5) = 1400
  MSFlexGrid1.ColWidth(6) = 900

rs.MoveLast
MSFlexGrid1.Rows = rs.RecordCount + 1
MSFlexGrid1.Cols = rs.Fields.Count
Dim i%
i = 1
rs.MoveFirst
While (Not rs.EOF)
       MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
      
        i = i + 1
     rs.MoveNext
     Wend
     Label8.Caption = i - 1
     Text4.Text = i - 1
     Call speed
     Else
    Label8.Caption = 0
     End If
End Sub
Sub speed()        '速度等参数计算程序
Dim i, Z, j
i = 1
Z = 0
 If Label8.Caption > 1 Then
 '总时间
 
     H1 = Mid(MSFlexGrid1.TextMatrix(1, 3), 1, 2)
     M1 = Mid(MSFlexGrid1.TextMatrix(1, 3), 4, 2)
     S1 = Mid(MSFlexGrid1.TextMatrix(1, 3), 7, 2)
     T1 = H1 + M1 / 60 + S1 / 3600
     
     H3 = Mid(MSFlexGrid1.TextMatrix((Label8.Caption - 1), 3), 1, 2)
     M3 = Mid(MSFlexGrid1.TextMatrix((Label8.Caption - 1), 3), 4, 2)
     S3 = Mid(MSFlexGrid1.TextMatrix((Label8.Caption - 1), 3), 7, 2)
     T4 = H3 + M3 / 60 + S3 / 3600
     
     H2 = Mid(MSFlexGrid1.TextMatrix(Label8.Caption, 3), 1, 2)
     M2 = Mid(MSFlexGrid1.TextMatrix(Label8.Caption, 3), 4, 2)
     S2 = Mid(MSFlexGrid1.TextMatrix(Label8.Caption, 3), 7, 2)
     T2 = H2 + M2 / 60 + S2 / 3600
     
     T3 = T2 - T1   '总时间
     T5 = T2 - T4    '瞬时时间
    ' Label23.Caption = T5
     
       '总路程
    While i < Label8.Caption
        BW11 = Mid(MSFlexGrid1.TextMatrix(i, 4), 1, 2)
        BW12 = Mid(MSFlexGrid1.TextMatrix(i, 4), 4, 7)
        BW13 = BW11 + BW12 / 90
        BW21 = Mid(MSFlexGrid1.TextMatrix(i + 1, 4), 1, 2)
        BW22 = Mid(MSFlexGrid1.TextMatrix(i + 1, 4), 4, 7)
        BW23 = BW21 + BW22 / 90
        BW = Abs(BW23 - BW13)
        'Format(BW, "0.00000")
        DJ11 = Mid(MSFlexGrid1.TextMatrix(i, 5), 1, 3)
        DJ12 = Mid(MSFlexGrid1.TextMatrix(i, 5), 5, 7)
        DJ13 = DJ11 + DJ12 / 90
        DJ21 = Mid(MSFlexGrid1.TextMatrix(i + 1, 5), 1, 3)
        DJ22 = Mid(MSFlexGrid1.TextMatrix(i + 1, 5), 5, 7)
        DJ23 = DJ21 + DJ22 / 90
        DJ = Abs(DJ23 - DJ13)
        y = 111 * BW
        x = 111 * Cos((BW13 + BW23) * 3.14 / 360) * DJ
        s = Sqr(x * x + y * y)
        Z = Z + s
        i = i + 1
        Wend
      Label16.Caption = Format(Z, "0.00")
      V1 = Z / T3
      V2 = s / T5
      Label11.Caption = Format(V1, "0.00")
      Label21.Caption = Format(V2, "0.00")
       p1 = Format(Atn(y / x) * 100 / 3.14, "00.00")  '弧度
               p2 = Mid(p1, 3, 3)
               p3 = Mid(p1, 1, 2)
               p4 = p3 + p2 * 90 / 100
               Label18.Caption = Format(p4, "00.00")
       If (DJ23 - DJ13) > 0 And (BW23 - BW13) < 0 Then
          Label14.Caption = "东偏南"
          Else
          If (DJ23 - DJ13) > 0 And (BW23 - BW13) > 0 Then
          Label14.Caption = "东偏北"
          Else
          If (DJ23 - DJ13) < 0 And (BW23 - BW13) < 0 Then
          Label14.Caption = "西偏南"
           Else
          If (DJ23 - DJ13) < 0 And (BW23 - BW13) > 0 Then
          Label14.Caption = "西偏北"
       End If
       End If
       End If
       End If
   Else
     MsgBox ("资源有限,无法得出里程、方向等相应数据")
     Label14.Caption = " 暂无"
     Label16.Caption = " 暂无"
     Label11.Caption = " 暂无"
     Label21.Caption = " 暂无"
     Label18.Caption = ""
   End If
End Sub

Private Sub Command2_Click()
response = MsgBox("确认要转到数据接收系统吗?", vbYesNo)
If response = vbYes Then
    Form2.Hide
    Form1.Show
End If
End Sub


Private Sub Command3_Click()
'给出一个消息框,确认是否要退出
response = MsgBox("真的要退出吗?", vbYesNo)
'用户按下"是"。
If response = vbYes Then
    Unload Me   '关闭窗体

    End   '退出整个应用程序
End If

End Sub


Private Sub Command4_Click()             '查找
     
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\我的文档\毕业设计\我的毕业设计\VB\测试\数据.mdb;Persist Security Info=False"
rs.CursorType = adOpenKeyset
rs.LockType = adLockBatchOptimistic
rs.Open "select * from GPS数据", conn
Call GridfindofADO(rs)
End Sub


Sub GridfindofADO(rs As ADODB.Recordset)                '查找子程序

If Text1.Text = "" And Text2.Text = "" Then       '输入时间为空时
'给出一个消息框,请输入要查询的起始时间
response = MsgBox("请输入要查询的起始时间", vbYesonly)
 '用户按下"是"。
   If response = vbYes Then
      Unload Me   '关闭窗体
        End If
     Else
If Not rs.Fields(0) = 0 Then
  Dim t11, t12, t13, t21, t22, t23, t31, t32, t33
  Dim T1, T2, T3
  MSFlexGrid1.TextMatrix(0, 0) = "时间"
  MSFlexGrid1.TextMatrix(0, 1) = "北纬"
  MSFlexGrid1.TextMatrix(0, 2) = "东经"
  MSFlexGrid1.TextMatrix(0, 3) = "处理后的时间"
  MSFlexGrid1.TextMatrix(0, 4) = "处理后的北纬"
  MSFlexGrid1.TextMatrix(0, 5) = "处理后的东经"
  MSFlexGrid1.TextMatrix(0, 6) = "所在城市"
  MSFlexGrid1.ColWidth(0) = 700
  MSFlexGrid1.ColWidth(1) = 1000
  MSFlexGrid1.ColWidth(2) = 1000
  MSFlexGrid1.ColWidth(3) = 1250
  MSFlexGrid1.ColWidth(4) = 1400
  MSFlexGrid1.ColWidth(5) = 1400
  MSFlexGrid1.ColWidth(6) = 900
rs.MoveLast
MSFlexGrid1.Rows = rs.RecordCount + 1
MSFlexGrid1.Cols = rs.Fields.Count
Dim i%
i = 1
rs.MoveFirst
   t11 = Mid(Text1.Text, 1, 2)
   t12 = Mid(Text1.Text, 4, 2)
   t13 = Mid(Text1.Text, 7, 2)
   T1 = t11 + t12 + t13

   
   t21 = Mid(Text2.Text, 1, 2)
   t22 = Mid(Text2.Text, 4, 2)
   t23 = Mid(Text2.Text, 7, 2)
   T2 = t21 + t22 + t23
  
While (Not rs.EOF)
   t31 = Mid(rs.Fields(3), 1, 2)
   t32 = Mid(rs.Fields(3), 4, 2)
   t33 = Mid(rs.Fields(3), 7, 2)
            
   
If t11 < t31 And t31 < t21 Then                              '1
       MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
      Else
      If t11 = t21 And t11 = t31 And t32 > t12 And t32 < t22 Then    '2
       MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
       Else
       If t21 > t11 And t11 = t31 And t32 > t12 Then   '3
       MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
      Else
    If t31 = t11 And t32 = t12 And t33 = t13 Then    '4
      MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
        Else
       If t21 > t11 And t21 = t31 And t32 < t22 Then   '5
      MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
          Else
      If t31 = t21 And t32 = t22 And t33 = t23 Then  '6
       MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
        Else
       If t21 = t11 And t11 = t31 And t22 = t12 And t32 = t22 And t33 <= t23 And t33 >= t13 Then  '7
       MSFlexGrid1.TextMatrix(i, 0) = rs.Fields(0)
       MSFlexGrid1.TextMatrix(i, 1) = rs.Fields(1)
       MSFlexGrid1.TextMatrix(i, 2) = rs.Fields(2)
       MSFlexGrid1.TextMatrix(i, 3) = rs.Fields(3)
       MSFlexGrid1.TextMatrix(i, 4) = rs.Fields(4)
       MSFlexGrid1.TextMatrix(i, 5) = rs.Fields(5)
       MSFlexGrid1.TextMatrix(i, 6) = rs.Fields(6)
        i = i + 1
             End If
          End If
         End If
        End If
       End If
      End If
      End If
     rs.MoveNext
     Wend
     Label8.Caption = i - 1
     Call speed
     
       Else
    Label8.Caption = 0
     End If
    End If
End Sub

Private Sub Command5_Click()         '清空表中数据
Dim i
If (Text4.Text >= Label8.Caption) Then
   i = Text4.Text
   Else
   i = Label8.Caption
   End If
While (i)
   MSFlexGrid1.TextMatrix(i, 0) = ""
   MSFlexGrid1.TextMatrix(i, 1) = ""
   MSFlexGrid1.TextMatrix(i, 2) = ""
   MSFlexGrid1.TextMatrix(i, 3) = ""
   MSFlexGrid1.TextMatrix(i, 4) = ""
   MSFlexGrid1.TextMatrix(i, 5) = ""
   MSFlexGrid1.TextMatrix(i, 6) = ""
   i = i - 1
Wend
Label16.Caption = ""
Label14.Caption = ""
Label11.Caption = ""
Label18.Caption = ""
Label21.Caption = ""
Label8.Caption = ""
End Sub
Private Sub Command6_Click()                '清空搜索参数
Text1.Text = ""
Text2.Text = ""
End Sub

我的问题是在下面这个界面无法实现查询功能
库操作应怎样做,Adodc控件的属性应怎么设置,求帮忙

搜索更多相关主题的帖子: 毕业 False 如何 
2013-05-15 19:48
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
得分:20 
没有查询条件
代码使用的是adodb不是adodc
两个GridshowofADO不出错吗?

无知
2013-05-17 13:04
kenan136
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-5-15
得分:0 
回复 2楼 Artless
请问怎么改才能实现查询功能,Adodc已经改了
查询条件怎么添加应该
2013-05-18 22:47
kenan136
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-5-15
得分:0 
回复 2楼 Artless
查询不就是根据自己输入的时间来查的吗?
2013-05-18 22:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-407177-1-1.html




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

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