早教吧 育儿知识 作业答案 考试题库 百科 知识分享

如何用vb画折线图?横坐标为一维数组的下标取值,纵坐标为对应数组元素的取值,最好有代码例i=2,3,4,5,6,7,8,9,10t(i)=0.8,0.6,0.5,0.4,0.3,0.2,0.1,0.05,0.02

题目详情
如何用vb画折线图?
横坐标为一维数组的下标取值,纵坐标为对应数组元素的取值,最好有代码
例i=2,3,4,5,6,7,8,9,10
t(i)=0.8,0.6,0.5,0.4,0.3,0.2,0.1,0.05,0.02
▼优质解答
答案和解析
参考代码:
Dim x2 As Integer '用来存储上一点的横坐标
Dim y2 As Integer '用来存储上一点的纵坐标
for k as integer = 2 to 10
if k=2 Then x2 = k : y2=t(k) '第一个点直接赋予坐标
Picture1.Line (k,t(k))-(x2,y2)
x2=k:y2=tk
next
存储坐标建议自定义Type,不建议使用数组下标来作为值的一部分
Type Point
X As Integer
Y As Integer
End Type
然后用数组Dim t(i) As Point来存储,
t(1).X = 2
t(1).Y = 3
这样比下标来存储点要好多了,因为下标是连续的,且只能为非负整数