在vb中通过数组画图
答案:3 悬赏:80 手机版
解决时间 2021-02-27 14:26
- 提问者网友:爱了却不能说
- 2021-02-27 11:11
请问哪位大侠知道如何在vb中通过一个数组画出一幅图,最好有相关的代码?
最佳答案
- 五星知识达人网友:詩光轨車
- 2021-02-27 11:54
我想你说的图就是“坐标曲线”,对吗?
Private Sub Command1_Click()
Me.Move 0, 0, Screen.Width, Screen.Height
'假设你的数据在数组z里面。z里第一个是横坐标值,第二个是纵坐标值,并假定一定排列好顺序
Dim z(1, 100) As Single, i As Integer, x As Single, y As Single
'因为我没有数据,这里随机产生。
For i = 0 To 100
Randomize
z(0, i) = i
z(1, i) = Rnd * 30 + 50
Next i
'画坐标轴
Me.Scale (-10, 120)-(120, -15)
Line (0, -10)-(0, 110)
Line (-10, 0)-(110, 0)
For i = -5 To 105 Step 5
Line (0, i)-(1, i)
Print i
Line (i, 1)-(i, 0)
Print i
Next i
x = z(0, 1)
y = z(1, 1)
Me.Circle (x, y), 0.5, vbRed
For i = 1 To 100
Line (x, y)-(z(0, i), z(1, i)), vbBlue
x = z(0, i)
y = z(1, i)
Me.Circle (x, y), 0.5, vbRed
Next i
End Sub
Private Sub Form_Load()
Me.Move 0, 0, Screen.Width, Screen.Height
Command1.Caption = "开始"
End Sub
Private Sub Command1_Click()
Me.Move 0, 0, Screen.Width, Screen.Height
'假设你的数据在数组z里面。z里第一个是横坐标值,第二个是纵坐标值,并假定一定排列好顺序
Dim z(1, 100) As Single, i As Integer, x As Single, y As Single
'因为我没有数据,这里随机产生。
For i = 0 To 100
Randomize
z(0, i) = i
z(1, i) = Rnd * 30 + 50
Next i
'画坐标轴
Me.Scale (-10, 120)-(120, -15)
Line (0, -10)-(0, 110)
Line (-10, 0)-(110, 0)
For i = -5 To 105 Step 5
Line (0, i)-(1, i)
Print i
Line (i, 1)-(i, 0)
Print i
Next i
x = z(0, 1)
y = z(1, 1)
Me.Circle (x, y), 0.5, vbRed
For i = 1 To 100
Line (x, y)-(z(0, i), z(1, i)), vbBlue
x = z(0, i)
y = z(1, i)
Me.Circle (x, y), 0.5, vbRed
Next i
End Sub
Private Sub Form_Load()
Me.Move 0, 0, Screen.Width, Screen.Height
Command1.Caption = "开始"
End Sub
全部回答
- 1楼网友:几近狂妄
- 2021-02-27 13:10
vb画图是通过点与点之间进行连线而成。给你个简单的代码。
先在窗体中添加一个picturebox控件,就可以在上面进行画图。
For i = 0 To acq_count * ch_cnt - 1
If k <> 0 Then
X = last_x(0)
Else
X = i / (DISP_COUNT - 1)
End If
samp = gnBuffer2(i)
Y = h - (CInt(CLng(samp) * h / 256))
If last_y(k) <> -1 Then
picScreen.Line (last_x(k), last_y(k))-(X, Y), shpColor(k).BackColor
End If
last_x(k) = X
last_y(k) = Y
Next
就这么简单!
- 2楼网友:雾月
- 2021-02-27 12:34
创建一个 textbox[] txt_array = new textbox[n] n= 你的textbox数量
然后 txt_array[0] = textbox1 依次添加进去 这样就可以了 数组只能自己手工创建的
我用的是c# 你改成vb的语法就可以了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯