重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
分类: 电脑/网络 程序设计 其他编程语言
成都创新互联公司-成都网站建设公司,专注做网站、网站建设、网站营销推广,申请域名,网络空间,网站托管有关企业网站制作方案、改版、费用等问题,请联系成都创新互联公司。
问题描述:
VB6中的form1.circle (100,200),rgb(0,255,0)的语句如何在VB中使用啊?
急用啊!!!!!!!!
解析:
VB与VB不同。
VB已经有专门绘图的类。
可以定义笔刷然后用Drawing类中的方法绘制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Function isopen() As AutoCAD.AcadApplication
Try
dim CADapp_temp AutoCAD.AcadApplication = GetObject(, "AutoCAD.Application")
return CADapp_temp
Catch ex As Exception
Return Nothing
End Try
End Function
'调用上面的函数,如果为nothing表示没有打开,否则打开并返回对象
不用PictureBoxTest.Image属性,直接把图形绘制到PictureBoxTest上面就可以了。
Dim button As Integer = 0
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles Button1.Click
Using g As Graphics = Graphics.FromHwnd(PictureBoxTest.Handle)
Dim penRed As Pen = New Pen(Color.Red, 1) '定义红色画笔
Dim penblue As Pen = New Pen(Color.Blue, 1) '定义蓝色画笔
If button = 0 Then
g.DrawLine(penRed, 0, 0, 100, 100)
button = 1
ElseIf button = 1 Then
g.DrawLine(penblue, 100, 100, 200, 200)
button = 0
End If
End Using
End Sub