VB2019 VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Codes 中文VB About Us

Drawing Pad Full Code



Dim x1 As Integer
Dim y1 As Integer
Dim x2 As Integer
Dim y2 As Integer
Dim x3 As Integer
Dim y3 As Integer
Dim color As String


Dim r As Integer


Private Sub Command1_Click()
On Error GoTo AddCoordinate


x1 = Text1.Text
y1 = Text2.Text
x2 = Text3.Text
y2 = Text4.Text


On Error GoTo addcolor

Picture1.Line (x1, y1)-(x2, y2), color
Exit Sub
AddCoordinate:
MsgBox ("Please fill in the coordinates")
Exit Sub

addcolor:

MsgBox ("Please choose a color")
Exit Sub



End Sub

Private Sub Command2_Click()
x1 = Val(Text1.Text)
y1 = Val(Text2.Text)
x2 = Val(Text3.Text)
y2 = Val(Text4.Text)
Picture1.Line (x1, y1)-(x2, y2), color, B

End Sub

Private Sub Command3_Click()
CommonDialog1.Flags = &H1&
CommonDialog1.ShowColor
color = CommonDialog1.color
End Sub

Private Sub Command4_Click()
On Error GoTo addvalues
x3 = Val(Text5.Text)
y3 = Val(Text6.Text)
r = Text7.Text
Picture1.FillStyle = vbSolid
Picture1.FillColor = color
Picture1.Circle (x3, y3), r, color


Exit Sub

addvalues:
MsgBox ("Please fill in the coordinates ,the radius and the color")



End Sub

Private Sub Command5_Click()
Picture1.Cls

End Sub

Private Sub Command6_Click()
x1 = Val(Text1.Text)
y1 = Val(Text2.Text)
x2 = Val(Text3.Text)
y2 = Val(Text4.Text)
Picture1.Line (x1, y1)-(x2, y2), color, BF

End Sub

Private Sub Picture1_Change()
'Change the coordinates of the origin
Scale (-5000, 5000)-(5000, -5000)
Me.Width = 10000
Me.Height = 10000
End Sub



Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy