【请教】vb.net参数无效问题

timeme 2010-09-15 05:38:18
我编了一个绘图程序如下:
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick



End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim y As Single
Dim x As Single
Dim g As Graphics = Me.PictureBox1.CreateGraphics
Dim mpen As New Pen(Color.Red)
Dim array As New List(Of PointF)
Dim Points As PointF()


Randomize()
y = 200 * Rnd()
array.Add(New PointF(x, y))
Points = array.ToArray
g.DrawLines(mpen, Points)
x = x + 1
End Sub
End Class

黄色部分是出错的地方,显示的参数无效的信息,请问一下如何解决?
谢谢!
...全文
141 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
兔子-顾问 2010-09-15
  • 打赏
  • 举报
回复
例如

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim y As Single
Dim x As Single
Dim g As Graphics = Me.PictureBox1.CreateGraphics
Dim mpen As New Pen(Color.Red)
Dim array As New List(Of PointF)
Dim Points As PointF()

Randomize()
y = 200 * Rnd()
array.Add(New PointF(x, y))
y = 200 * Rnd()
array.Add(New PointF(x, y))
Points = array.ToArray
g.DrawLines(mpen, Points)
x = x + 1
End Sub
End Class
兔子-顾问 2010-09-15
  • 打赏
  • 举报
回复
因为你只添加了一个点,所以绘制线条失败。多加几个点就可以看到了。至少2个点。

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧