vb编程,画直线

vb编程,画直线,第1张

窗体中添加一个Command1按钮,复制如下代码,点击命令按钮后,清屏然后随机画出20条线段

Private Sub Command1_Click()

Dim I As Integer, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer

Dim ColorR As Long, ColorG As Long, ColorB As Long, DrawColor As Long

Randomize

Cls

ScaleMode = 3 ' 设置 ScaleMode 为像素

DrawMode = 13 '输出外观(前景色与背景色的 *** 作方式)

DrawStyle = 0 '线条样式

'【0(缺省值)实线,1 虚线,2 点线,3 点划线,4 双点划线,5 无线,6 内收实线】

For I = 1 To 20

X1 = Rnd * Me.ScaleWidth

Y1 = Rnd * Me.ScaleHeight

X2 = Rnd * Me.ScaleWidth

Y2 = Rnd * Me.ScaleHeight

DrawWidth = Rnd * 10 + 1 '线条宽度,数值可选为1~32767,不过太大了就无法分辨了

ColorR = Rnd * 256

ColorG = Rnd * 256

ColorB = Rnd * 256

DrawColor = (((256 * ColorR) + ColorG) * 256) + ColorB

ForeColor = DrawColor

Line (X1, Y1)-(X2, Y2)

Next

End Sub

Private Sub Check1_Click()

Label1.Font.Underline = IIf(Check1.Value = vbChecked, True, False)

End Sub

Private Sub Check2_Click()

Label1.Font.Strikethrough = IIf(Check2.Value = vbChecked, True, False)

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11389844.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存