vb怎么使用Line方法在窗体上绘制
展开全部
Private Sub Command1_Click()
Dim x0 As Integer, y0 As Integer
Dim a(10, 2) As Integer
Dim i As Integer, j As Integer
x0 = 2000
y0 = 1500
For i = 0 To 10
a(i, 1) = 1500 * Cos(36 * i / 180 * 3.14159265)
a(i, 2) = 1500 * Sin(36 * i / 180 * 3.14159265)
Next
For i = 1 To 10
For j = 1 To i - 1
Line (x0 + a(i, 1), y0 + a(i, 2))-(x0 + a(j, 1), y0 + a(j, 2))
Next
Next
End Sub
展开全部
呵呵。首先要自定义一个以窗体中心为(0,0)的坐标系。
其次要以小于窗体宽度的长度,每36度为一个角度,求出其sin值,并确定十个点的坐标值,将这些坐标在于一个数组中。
最后就是用循环来依次连线了。
以上思路供参考。朋友。
其次要以小于窗体宽度的长度,每36度为一个角度,求出其sin值,并确定十个点的坐标值,将这些坐标在于一个数组中。
最后就是用循环来依次连线了。
以上思路供参考。朋友。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim X(0 To 9) As Double '数组保存10个点的横坐标
Dim Y(0 To 9) As Double '保存10个点的纵坐标
Dim Cx As Double '圆心的横坐标
Dim Cy As Double '圆心的纵坐标
Dim r As Double '半径
Dim i As Integer
Dim j As Integer
Const Pi = 3.14159 '圆周率
Me.Cls
'圆心定在窗体中间
Cx = Me.ScaleWidth / 2
Cy = Me.ScaleHeight / 2
'半径设定为窗体可用的宽或高中的较小者
r = IIf(Me.ScaleWidth > Me.ScaleHeight, _
Cy, Cx)
'计算10个点的坐标,每点相隔36度
For i = 0 To 9
X(i) = Cx + r * Sin((18 + i * 36) * Pi / 180)
Y(i) = Cy - r * Cos((18 + i * 36) * Pi / 180)
Next
'点与点之间连线
For i = 0 To 9
For j = i To 9
Me.Line (X(i), Y(i))-(X(j), Y(j))
Next
Next
Dim Y(0 To 9) As Double '保存10个点的纵坐标
Dim Cx As Double '圆心的横坐标
Dim Cy As Double '圆心的纵坐标
Dim r As Double '半径
Dim i As Integer
Dim j As Integer
Const Pi = 3.14159 '圆周率
Me.Cls
'圆心定在窗体中间
Cx = Me.ScaleWidth / 2
Cy = Me.ScaleHeight / 2
'半径设定为窗体可用的宽或高中的较小者
r = IIf(Me.ScaleWidth > Me.ScaleHeight, _
Cy, Cx)
'计算10个点的坐标,每点相隔36度
For i = 0 To 9
X(i) = Cx + r * Sin((18 + i * 36) * Pi / 180)
Y(i) = Cy - r * Cos((18 + i * 36) * Pi / 180)
Next
'点与点之间连线
For i = 0 To 9
For j = i To 9
Me.Line (X(i), Y(i))-(X(j), Y(j))
Next
Next
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询