0% found this document useful (0 votes)
130 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)
130 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
You are on page 1/ 7

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:

Picture1.Line (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

Picture1.Line (x1, y1)-(x2, y2), color, B

The syntax to draw a solid rectangle is

Picture1.Line (x1, y1)-(x2, y2), color, BF

The syntax to draw a circle is

Picture1.Circle (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:

Picture1.FillStyle = vbSolid
Picture1.FillColor = color

The syntax to clear the picture is

Picture1.Cls
The Interface

The code

Private Sub cmd_Rectangle_Click()


x1 = Text1.Text
y1 = Text2.Text
x2 = Text3.Text
y2 = Text4.Text
Picture1.Line (x1, y1)-(x2, y2), color, B
End Sub
Private Sub cmd_Color_Click()
CommonDialog1.Flags = &H1&
CommonDialog1.ShowColor
color = CommonDialog1.color

End Sub

Private Sub cmd_Circle_Click()


On Error GoTo addvalues
x3 = Text5.Text
y3 = 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 cmd_SolidRect_Click()


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

The Interface
The code

Private Sub Form_Load()


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

Private Sub Combo1_Change()


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

End Sub

Private Sub Dir1_Change()


File1.Path = Dir1.Path
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.wav")
ElseIf Combo1.ListIndex = 1 Then
File1.Pattern = ("*.mid")
ElseIf Combo1.ListIndex = 2 Then
File1.Pattern = ("*.avi")
ElseIf Combo1.ListIndex = 3 Then
File1.Pattern = ("*.mpeg;*.mpg;*.mp3")
Else
File1.Pattern = ("*.*")
End If
End Sub

Private Sub Drive1_Change()


Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()


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

If Right(File1.Path, 1) <> "\" Then


filenam = File1.Path + "\" + File1.FileName
Else
filenam = File1.Path + File1.FileName
End If
Text1.Text = filenam

End Sub

Private Sub Open_Click()


If Combo1.ListIndex = 0 Then
MMControl1.DeviceType = "WaveAudio"
End If
If Combo1.ListIndex = 1 Then
MMControl1.DeviceType = "Sequencer"
End If

If Combo1.ListIndex = 2 Then
MMControl1.DeviceType = "AVIVideo"
End If
If Combo1.ListIndex = 3 Then
MMControl1.DeviceType = ""

End If

MMControl1.FileName = Text1.Text
MMControl1.Command = "Open"
End Sub

Private Sub play_Click()


Timer1.Enabled = True
MMControl1.Command = "Play"
MMControl1.hWndDisplay = Picture1.hWnd
End Sub

Private Sub Stop_Click()


If MMControl1.Mode = 524 Then Exit Sub
If MMControl1.Mode <> 525 Then
MMControl1.Wait = True
MMControl1.Command = "Stop"
End If
MMControl1.Wait = True
MMControl1.Command = "Close"
End Sub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy