主题:[讨论]小妹程序遇到点问题,请各位帮帮忙修改修改
[color=000080]picture怎样调用DataGrid1中显示出来的数据画图:[/color]
Private Sub ComHistory_Click() '查询历史数据的过程
'On Error Resume Next
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select * from Tabres order by 编号 desc", cn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
'***************开始在 Picture1中调用DataGrid1中显示出来的数据进行画图。
Picture1 = rs.DataSource
Dim j As Integer
Picture1.Cls '首先清除picture1内的图形
Picture1.ScaleMode = 0 'Scale方法设定用户坐标系,坐标原点在Picture1中心
Picture1.Scale (0, 50)-(720, 0)
Picture1.DrawWidth = 1 '设置绘线宽度
Picture1.ForeColor = vbBlue
For j = 2 To 720 'X坐标标定的数字
Picture1.CurrentX = j * 0.5 '指定数字的显示位置
Picture1.CurrentY = -0.5
Picture1.Print j
Next j
For j = 1 To 50 'Y坐标标定的数字
Picture1.CurrentX = -(0.5) '指定数字的显示位置
Picture1.CurrentY = 2 * j
Picture1.Print j
Next j
Picture1.CurrentX = 0.5 '指定“1”的显示位置
Picture1.CurrentY = -0.5
Picture1.Print "1"
Picture1.DrawWidth = 2 '重设绘线宽度
Dim DataStr() As String
Dim X As Single, Yi As Double
Dim i, dx As Long
ReDim DataStr(1 To rs.RecordCount)
'************************************ 横坐标取时设置
dx = 1
For i = 0 To rs.RecordCount '设定X坐标的数字间距
X = X + dx
Yi = DataStr(i)
Picture1.CurrentX = X '指定位置显示原点O
Picture1.CurrentY = Yi
Picture1.Print Yi
Next i
'***************************************
dx = 1
X = 0
Yi = 0
i = 0
For i = 0 To rs.RecordCount '设定X坐标的数字间距
X = X + dx
Yi = DataStr(i)
Picture1.Line -(X, Yi) '相当于确定所画直线的斜率
Next i
Picture1.CurrentX = 2 '指定位置显示描述文字
Picture1.CurrentY = -3
Picture1.ForeColor = vbBlack
Picture1.Print "通道1数值的曲线示意"
End Sub
[color=800080]运行以上代码,发现出的图形是混乱的,而且还报错“下标越界”,小妹是VB初学者,实在是搞不懂怎么去修改,请各位帮帮忙看看,在此先谢谢了哈![/color]