Download presentation
Presentation is loading. Please wait.
1
Mark Dixon, SoCCE SOFT 131Page 1 22 – Visual BASIC 2005
2
Mark Dixon, SoCCE SOFT 131Page 2 Session Aims & Objectives Aims –introduce you to the fundamentals of: VB2005 development environment –stand-alone.exe –PocketPC/SmartPhone.exe –activeX control Objectives, by end of this week’s sessions, you should be able to: –develop 'stand alone' applications –put bitmap (raster) graphics into your applications –draw simple vector graphics in your applications –play MP3 and WAV files in your applications
3
Mark Dixon, SoCCE SOFT 131Page 3 VB2005 IDE Microsoft Visual BASIC 2005 IDE: Integrated Development Environment –Screen (form) designer –Code editor –Debugger –Help Start menu, Programs, University Software, M, Microsoft Visual Studio 2005
4
Mark Dixon, SoCCE SOFT 131Page 4 Example: PicView - Analysis SPECIFICATION User Requirements –display photos quickly and easily one after another Software Requirements –Functional: –change current folder and drive –display list of picture files in current folder –display picture (*.jpg, *.bmp, and *.gif) from files in current folder –Non-functional should be quick and easy to use
5
Mark Dixon, SoCCE SOFT 131Page 5 Example: PicView - Design User interface design: Functional design: Trigger (when)Actions (what) click event of Drive Boxmake drive current (directory box points to this drive) click event of Directory Boxmake folder current (file box points to this folder) click event of File Boxdisplay selected picture in picture box
6
Mark Dixon, SoCCE SOFT 131Page 6 New Project: Windows Application Stand-alone windows application (.exe) File menu, new project item
7
Mark Dixon, SoCCE SOFT 131Page 7 VB2005 IDE
8
Mark Dixon, SoCCE SOFT 131Page 8 Controls: Standard Picture Box: display pictures
9
Mark Dixon, SoCCE SOFT 131Page 9 Controls: Add VB 2005 can't show all controls (too many) choose which to include –Right click toolbox –Select 'Choose items…' option
10
Mark Dixon, SoCCE SOFT 131Page 10 Controls: additions Drive List Box: allow user to select disk drive Directory List Box: allow user to select folder File List Box: allow user to select file
11
Mark Dixon, SoCCE SOFT 131Page 11 Controls' Properties Picture Box (pic) –Picture: allows display of bitmap (raster graphic) as background Drive List Box (drv) –Drive: the currently selected disk drive Directory List Box (dir) –Path: the currently selected directory (folder) File List Box (fil) –Path: the currently selected folder/directory –Pattern: only display this type of file (e.g..jpg) –FileName: the currently selected file
12
Mark Dixon, SoCCE SOFT 131Page 12 Example: PicView - Code Public Class frmPicView Private Sub frmPicView_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load filMain.Pattern = "*.jpg;*.gif" End Sub Private Sub dirMain_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dirMain.MouseUp filmain.Path = dirmain.Path End Sub Private Sub filMain_SelectedIndexChanged( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles filMain.SelectedIndexChanged picMain.Image = Image.FromFile(filMain.Path & "/" & filMain.FileName) End Sub End Class dirMain (Directory List) filMain (File List) picMain (Picture Box)
13
Mark Dixon, SoCCE SOFT 131Page 13 Example: Music Player - Analysis User Requirement: –to play different music for long time without interruption, at same location (while working or at party) Software Requirements Specification software should: –allow user to: select track (MP3 file) from folder on disk play selected track –automatically move to next track in folder go back to first after last has played later lecture
14
Mark Dixon, SoCCE SOFT 131Page 14 Multimedia Control Right click toolbox select 'choose items…' select COM tab Multimedia Control –plays MP3 & WAV files
15
Mark Dixon, SoCCE SOFT 131Page 15 Multimedia Controls' Properties Multi-media Control –FileName: name of file to play –Command: controls playback
16
Mark Dixon, SoCCE SOFT 131Page 16 Example: Music Player - Design Compare the following User Interface Designs: V0 V1
17
Mark Dixon, SoCCE SOFT 131Page 17 Example: Music Player - Code mmcMain.Command = "Close" mmcMain.FileName = filMain.Path & "\" & filMain.FileName mmcMain.Command = "Open" drvMain dirMain filMain mmcMain
18
Mark Dixon, SoCCE SOFT 131Page 18 Types of Graphics: Raster Raster graphics – made of dots (pixels – picture elements) –stored in.jpg,.bmp, and.gif files (picture property) –suitable for complex, static pictures (e.g. photos) –difficult to change programmatically –loses quality when enlarged:
19
Mark Dixon, SoCCE SOFT 131Page 19 Types of Graphics: Vector Vector graphics – made of objects (lines, circles, etc.) –not available in VB Script or HTML –suitable for simple, dynamic pictures (diagrams) –No loss of quality when enlarged
20
Mark Dixon, SoCCE SOFT 131Page 20 Vector Graphics: Grid System the origin (position 0,0) is at top left –in mathematics it is always bottom left
21
Mark Dixon, SoCCE SOFT 131Page 21 Picture Box: Drawing Methods Picture Box has –CreateGraphics object Methods (vector graphics) –DrawLine : draws a straight line between 2 points –DrawEllipse: draws an ellipse/circle –PSet: draws a dot (point) –Clear: clears (screen) drawing area
22
Mark Dixon, SoCCE SOFT 131Page 22 Example: Face Face
23
Mark Dixon, SoCCE SOFT 131Page 23 Example: Face v2 Face
24
Mark Dixon, SoCCE SOFT 131Page 24 Mobile Applications New Project –Smart Devices
25
Mark Dixon, SoCCE SOFT 131Page 25 Tutorial Exercise: PicView Task 1: Get the PicView example (from the lecture) working. Task 2: Get the StickMan example (from the lecture) working. Task 3: Get the Music Player example (from the lecture) working. Task 4: Modify your program to automatically go the next track after the current one ends. Task 5: Modify your program to automatically go the first track after the last one ends. Task 6: Get the Face v2 example (from the lecture working).
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.