| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3639 人关注过本帖
标题:求助,关于数据库中数据保存到数组
取消只看楼主 加入收藏
瞬间暴炸
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2017-4-11
结帖率:0
收藏
已结贴  问题点数:10 回复次数:1 
求助,关于数据库中数据保存到数组
朋友们,我想把数据库(data.mdb)中表(davis)中的两个字段(字段1、字段2)中数据保存到两个数组中,然后在picture上作为X、Y坐标显示出来,最后连接这些点做成一个折线图。下面是我的代码。
Private Sub Command4_Click()
Picture1.Cls
Picture1.ScaleMode = 0.5
Picture1.Scale (-2, 10)-(10, -10)
Picture1.DrawWidth = 1
Picture1.Line (-1, 0)-(9, 0), vbBlue
Picture1.Line (8.5, 0.5)-(9, 0), vbBlue
Picture1.Line (8.5, -0.5)-(9, 0), vbBlue
Picture1.ForeColor = vbBlue
Picture1.Print "X"
Picture1.Line (0, -9)-(0, 9), vbBlue
Picture1.Line (0.2, 8.5)-(0, 9), vbBlue
Picture1.Line (-0.2, 8.5)-(0, 9), vbBlue
Picture1.Print "Y"
For i = -8 To 8 Step 2
Picture1.CurrentX = 0
Picture1.CurrentY = i
Picture1.PSet (0.02, i)
Picture1.Print i
Next
For i = 0 To 8 Step 1
Picture1.CurrentX = i
Picture1.CurrentY = 0
Picture1.PSet (i, 0.02)
Picture1.Print i
Next                            以上是坐标系得代码,已经运行,没有错误。

    Dim Conn As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim m As Long, Rc As Long
    Dim Zx() As Double, Zy() As Double
    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data.mdb;Persist Security Info=False"
    Conn.Open "select 字段1,字段2 from Davis", Conn, 1, 1
    Rc = Rs.RecordCount
    ReDim Zx(Rc) As Double
    ReDim Zy(Rc) As Double
    For m = 0 To Rc - 1
        Zx(m) = Rs(0)
        Zy(m) = Rs(1)
        Rs.MoveNext
    Next
    For m = 0 To 9
    Line (Zx(m), Zy(m))-(Zx(m), Zy(m))
    Next
End Sub              以上是在picture上表达出来,然后画折线图


最后程序还是无法运行,,求各位帮帮忙!!谢谢

搜索更多相关主题的帖子: 数据库 朋友 
2017-04-13 18:32
瞬间暴炸
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2017-4-11
收藏
得分:0 
回复 2楼 风吹过b
Private Sub Command4_Click()
Picture1.Cls
Picture1.ScaleMode = 0.5
Picture1.Scale (-2, 10)-(10, -10)
Picture1.DrawWidth = 1
Picture1.Line (-1, 0)-(9, 0), vbBlue
Picture1.Line (8.5, 0.5)-(9, 0), vbBlue
Picture1.Line (8.5, -0.5)-(9, 0), vbBlue
Picture1.ForeColor = vbBlue
Picture1.Print "X"
Picture1.Line (0, -9)-(0, 9), vbBlue
Picture1.Line (0.2, 8.5)-(0, 9), vbBlue
Picture1.Line (-0.2, 8.5)-(0, 9), vbBlue
Picture1.Print "Y"
For i = -8 To 8 Step 2
Picture1.CurrentX = 0
Picture1.CurrentY = i
Picture1.PSet (0.02, i)
Picture1.Print i
Next
For i = 0 To 8 Step 1
Picture1.CurrentX = i
Picture1.CurrentY = 0
Picture1.PSet (i, 0.02)
Picture1.Print i
Next

Dim Conn As New ADODB.Connection
    Dim Rs As New ADODB.Recordset
    Dim i As Long, Rc As Long
    Dim zX() As Single, zY() As Single
   
    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb;Jet OLEDB:Database password="
    Conn.Open
    Rs.Open "select 编号,饱和指数 from Davis", Conn, 1, 1
    Rc = Rs.RecordCount
    ReDim zX(Rc) As Single, zY(Rc) As Single
    For i = 1 To Rc
        zX(i) = Rs(0)
        zY(i) = Rs(1)
        Rs.MoveNext
    Next
    Rs.Close
    Conn.Close
   
    Pic.Scale (0, 7)-(12, 4)
    For i = 1 To Rc - 1
        Pic.Line (zX(i), zY(i))-(zX(i + 1), zY(i + 1))
    Next
End Sub


这是修改过的,,还是不对
2017-04-13 21:59
快速回复:求助,关于数据库中数据保存到数组
数据加载中...
 
   



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

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