| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 667 人关注过本帖
标题:请教同时显示双曲线问题?
只看楼主 加入收藏
huluting
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-13
收藏
 问题点数:0 回复次数:1 
请教同时显示双曲线问题?
我在调试我的程序时,为什么显示不了第二条曲线?以下是我的工程。谢谢!
搜索更多相关主题的帖子: 双曲线 工程 调试 
2006-04-11 10:12
huluting
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-1-13
收藏
得分:0 

Option Explicit
Private Values() As Variant
Private NumPoints As Integer


Private Sub LoadData()
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rs1 As ADODB.Recordset
Dim dbname As String
Dim i As Integer
Dim dbfilename As String
Dim ConnectString As String
Dim apppath As String

' 打开数据库
Dim strsql As String
Set db = New ADODB.Connection
If Right(App.Path, 1) = "\" Then
apppath = App.Path
Else
apppath = App.Path & "\"
End If
dbfilename = apppath & "data.mdb"
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
dbfilename & ";Persist Security Info=False;"

On Error Resume Next
With db
.CursorLocation = adUseClient
.Open ConnectString
End With
' 获得数据库记录

Set rs = New ADODB.Recordset
strsql = " select * from bysj where bysj.date between #" & Textmindate & "# and #" & Textmaxdate & "#"
rs.Open strsql, db, 2, 3

' 查看数据库中记录数
rs.MoveLast
NumPoints = rs.RecordCount
ReDim Values(1 To NumPoints, 1 To 2)

' 加载数据
rs.MoveFirst
For i = 1 To NumPoints
Values(i, 1) = rs!Date
Values(i, 2) = rs!流量
rs.MoveNext
Next i
rs.Close
db.Close
End Sub

Private Sub Comexit_Click()
Unload Me
End Sub
Private Sub Command1_Click()
With MSChart1
.Top = 0
.Left = 0
.Width = Me.ScaleWidth
.Height = Me.ScaleHeight
End With
LoadData
If CDate(Textmaxdate.Text) < CDate(Textmindate.Text) Then
MsgBox "后面的日期应大于前面的!" + Chr(13) + "为了选出您想要的记录请修改过来.", 48, "日期错误"
Textmaxdate.SelStart = 0
Textmaxdate.SelLength = 8
Textmaxdate.SetFocus
Exit Sub
End If
Dim sql
sql = "select * from bysj where date between " + Chr(35) + Textmindate + Chr(35) + " and " + Chr(35) + Textmaxdate + Chr(35) + " order by date"
Adodc1.RecordSource = sql
Adodc1.Refresh
' 使用MSChart控件显示数据
MSChart1.ChartData = Values
MSChart1.RowCount = NumPoints
MSChart1.chartType = VtChChartType2dLine
MSChart1.Visible = True

End Sub

Private Sub Textmindate_LostFocus()
If Not IsDate(Textmindate.Text) Then
Textmindate.SelStart = 0
Textmindate.SelLength = 8
Textmindate.SetFocus
End If
End Sub
Private Sub Textmaxdate_LostFocus()
If Not IsDate(Textmaxdate.Text) Then
Textmaxdate.SelStart = 0
Textmaxdate.SelLength = 8
Textmaxdate.SetFocus
' Exit Sub
End If
End Sub

Public Function getNextValue(ByVal myDate As Date, ByVal n As Integer) As Double
Set rs1 = New ADODB.Recordset
Dim t As Double
myDate = Textmindate
Do While myDate < Textmaxdate
Set rs1 = db.Execute("SELECT TOP " & 3 & " 流量 FROM bysj WHERE date<#" & myDate & "# ORDER BY date DESC")
rs1.MoveFirst
While Not rs1.EOF
t = t + rs.Fields(0).Value
rs1.MoveNext
Wend
Set rs1 = Nothing
getNextValue = t / 2
myDate = DateAdd("n", 5, myDate)
Line (getNextValue, Textmindate)-(getNextValue, myDate), vbGreen
rs1.Close
Line (Textmindate, getNextValue)-(myDate, getNextValue)
Loop
End Function

2006-04-11 10:13
快速回复:请教同时显示双曲线问题?
数据加载中...
 
   



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

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