2个回答
展开全部
Private Type tPoint
x As Single
y As Single
End Type
Private Sub Form_Load()
HScroll1.Min = 0
HScroll1.Max = 360
End Sub
Private Sub fun_Paint()
Const PI As Double = 3.141592653
Dim intR As Integer
Dim intO As tPoint
Dim intK As Integer
Dim pp(4) As tPoint
Dim i As Integer
Me.Cls
Me.AutoRedraw = True
intR = Int(Val(Text1.Text))
intO.x = Int(Val(Text2.Text))
intO.y = Int(Val(Text3.Text))
intK = Me.HScroll1.Value
Me.DrawWidth = 10
Me.PSet (intO.x, intO.y), vbRed
For i = 0 To 4
pp(i).x = intO.x + intR * Sin(((intK + 72 * i) / 360) * (2 * PI))
pp(i).y = intO.y + intR * Cos(((intK + 72 * i) / 360) * (2 * PI))
Me.DrawWidth = 6
Me.PSet (pp(i).x, pp(i).y), vbBlue
Next i
Me.DrawWidth = 3
For i = 0 To 4
Me.Line (pp(i).x, pp(i).y)-(pp((i + 2) Mod 5).x, pp((i + 2) Mod 5).y), vbBlack
Next
End Sub
Private Sub Form_Click()
fun_Paint
End Sub
Private Sub HScroll1_Change()
fun_Paint
End Sub
Private Sub HScroll1_Scroll()
fun_Paint
End Sub
展开全部
楼主看看这个:
' 窗体内画一个水平滚动条 HScroll1 、一个按钮 Command1
Private Const PI As Double = 3.14159265359 '圆周率 π
Private mlR As Long
Private Sub DrawPentacle()
Dim w As Long, h As Long
Dim i As Long, a As Double
Dim v As Long, p As Long
Dim xa#, xb#, ya#, yb#
v = HScroll1.Value
w = ScaleWidth / 2
h = ScaleHeight / 2
Me.Cls: p = 0
a = v * PI / 180
xa = w + mlR * Sin(a)
ya = h - mlR * Cos(a)
For i = 1 To 5
p = (p + 2) Mod 5
a = ((v + 72 * p) * PI / 180)
xb = w + mlR * Sin(a)
yb = h - mlR * Cos(a)
Line (xa, ya)-(xb, yb), vbRed
xa = xb: ya = yb
Next
End Sub
Private Sub Command1_Click()
Dim v As Long
v = Val(InputBox("请输入半径(以象素为单位):", "输入", "150"))
If (v < 1 Or v > 800) Then
MsgBox "输入不正确。", 32
Exit Sub
End If
mlR = v
Call DrawPentacle
End Sub
Private Sub Form_Load()
ScaleMode = 3
HScroll1.TabStop = False
HScroll1.Min = 0
HScroll1.Max = 360
End Sub
Private Sub HScroll1_Change()
Call DrawPentacle
End Sub
Private Sub HScroll1_Scroll()
Call DrawPentacle
End Sub
更多追问追答
追答
你新建一个工程,按我的代码、说明做呗。
看你的代码,能画出五角星吗……
你要让别人给你改代码,直接贴代码啊或发工程啊,
你贴图片,别人要把你的代码“敲一遍”,你不认为很劲吗!!!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询