0% found this document useful (0 votes)
187 views7 pages

To Create The Drawing Pad Using Visual Basic

The document describes the code and interface for a drawing pad application. It includes instructions for drawing various shapes like lines, rectangles, and circles using picture box syntax. It also explains how to insert common controls like a picture box, text boxes, and command buttons to create the interface. Additional code provides functionality for selecting colors using a common dialog, clearing the picture, and playing/stopping media files using MMControl commands.

Uploaded by

sacay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views7 pages

To Create The Drawing Pad Using Visual Basic

The document describes the code and interface for a drawing pad application. It includes instructions for drawing various shapes like lines, rectangles, and circles using picture box syntax. It also explains how to insert common controls like a picture box, text boxes, and command buttons to create the interface. Additional code provides functionality for selecting colors using a common dialog, clearing the picture, and playing/stopping media files using MMControl commands.

Uploaded by

sacay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

To create the drawing pad, you need to insert a common dialog control, a

picture box, four text boxes , six command buttons and the necessary labels. The
function of the common dialog control is to assist the users to choose colors. The text
boxes are for the user to enter the coordinates and the picture box is to display the
pictures drawn. The method to draw a straight line is Line, and the syntax is as follows:

[Link] (x1, y1)-(x2, y2), color

where picture1 is the picture box, (x1,y1) is the coordinates of the starting point, (x2,
y2) is the ending point and color understandably is the color of the line.

The syntax to draw a non-solid rectangle is

[Link] (x1, y1)-(x2, y2), color, B

The syntax to draw a solid rectangle is

[Link] (x1, y1)-(x2, y2), color, BF

The syntax to draw a circle is

[Link] (x3, y3), r, color

Where (x3, y3) is the center of the circle and r is the radius.

f you wish to draw a solid circle and fill it with the selected color, then add two more
lines to the above syntax:

[Link] = vbSolid
[Link] = color

The syntax to clear the picture is

[Link]
The Interface

The code

Private Sub cmd_Rectangle_Click()


x1 = [Link]
y1 = [Link]
x2 = [Link]
y2 = [Link]
[Link] (x1, y1)-(x2, y2), color, B
End Sub
Private Sub cmd_Color_Click()
[Link] = &H1&
[Link]
color = [Link]

End Sub

Private Sub cmd_Circle_Click()


On Error GoTo addvalues
x3 = [Link]
y3 = [Link]
r = [Link]

[Link] = vbSolid
[Link] = color
[Link] (x3, y3), r, color
Exit Sub

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

End Sub

Private Sub Command5_Click()


[Link]
End Sub

Private Sub cmd_SolidRect_Click()


x1 = [Link]
y1 = [Link]
x2 = [Link]
y2 = [Link]
[Link] (x1, y1)-(x2, y2), color, BF
End Sub

The Interface
The code

Private Sub Form_Load()


Left = ([Link] - Width) \ 2
Top = ([Link] - Height) \ 2
'To offer the user selection of media files
[Link] = "*.wav"
[Link] "*.wav"
[Link] "*.mid"
[Link] "*.avi"
[Link] "*.mpeg;*.mpg;*.mp3"
[Link] "All files"
End Sub

Private Sub Combo1_Change()


'To allow the user to select a particular media file type
If ListIndex = 0 Then
[Link] = ("*.wav")
ElseIf ListIndex = 1 Then
[Link] = ("*.mid")
ElseIf ListIndex = 2 Then
[Link] = ("*.avi")
ElseIf ListIndex = 3 Then
[Link] = ("*.mpeg;*.mpg;*.mp3")
Else
[Link] = ("*.*")
End If

End Sub

Private Sub Dir1_Change()


[Link] = [Link]
If [Link] = 0 Then
[Link] = ("*.wav")
ElseIf [Link] = 1 Then
[Link] = ("*.mid")
ElseIf [Link] = 2 Then
[Link] = ("*.avi")
ElseIf [Link] = 3 Then
[Link] = ("*.mpeg;*.mpg;*.mp3")
Else
[Link] = ("*.*")
End If
End Sub

Private Sub Drive1_Change()


[Link] = [Link]
End Sub

Private Sub File1_Click()


'Allows the user to select a particular media file
If [Link] = 0 Then
[Link] = ("*.wav")
ElseIf [Link] = 1 Then
[Link] = ("*.mid")
ElseIf [Link] = 2 Then
[Link] = ("*.avi")
ElseIf [Link] = 3 Then
[Link] = ("*.mpeg;*.mpg;*.mp3")
Else
[Link] = ("*.*")
End If

If Right([Link], 1) <> "\" Then


filenam = [Link] + "\" + [Link]
Else
filenam = [Link] + [Link]
End If
[Link] = filenam

End Sub

Private Sub Open_Click()


If [Link] = 0 Then
[Link] = "WaveAudio"
End If
If [Link] = 1 Then
[Link] = "Sequencer"
End If

If [Link] = 2 Then
[Link] = "AVIVideo"
End If
If [Link] = 3 Then
[Link] = ""

End If

[Link] = [Link]
[Link] = "Open"
End Sub

Private Sub play_Click()


[Link] = True
[Link] = "Play"
[Link] = [Link]
End Sub

Private Sub Stop_Click()


If [Link] = 524 Then Exit Sub
If [Link] <> 525 Then
[Link] = True
[Link] = "Stop"
End If
[Link] = True
[Link] = "Close"
End Sub

You might also like