Introduction to VB6 Week 1 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup PPCC - Introduction to VB6
Materials & Prerequisites Software: Visual Basic 6.0 A Working Model in included with the book Course will target the VB 6 Professional Edition Check with MS for free 90 day trial edition Participant CD VB 6 Service Pack 5 http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/default.aspx Microsoft Jet 4.0 Service Pack 8 http://www.microsoft.com/downloads/results.aspx?productID=3D99F106-AA6D-4113-AE45-30B61394B1E0&freetext=&DisplayLang=en Get the one that matches your system!!! Microsoft Data Access Components (MDAC) downloads can be found from: http://msdn.microsoft.com/data/downloads/updates/default.aspx Microsoft Data Access Components (MDAC) 2.7 SP1 Refresh http://www.microsoft.com/downloads/details.aspx?familyid=9ad000f2-cae7-493d-b0f3-ae36c570ade8&languageid=f49e8428-7071-4979-8a67-3cffcb0c2524&displaylang=en MDAC Buffer Overrun Secrity Patch MS04-003 http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/Bulletin/MS04-003.asp 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup PPCC - Introduction to VB6
Course Outline, Week 1 Getting Started with VB6 Installation & Setup of VB6 for development Launching VB6 VB6 Settings The VB6 IDE 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup PPCC - Introduction to VB6
Course Outline, Week 1 Your first app (Hello World) Running the application Calculating an approximation of PI Very simple – use 22/7, but use controls for input/output Designing a user interface 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup PPCC - Introduction to VB6
Course Outline , Week 1 Adding code to your application Visual Basic Statements Simple Variable and Constant Declarations Assignment Statements and Expressions If … Then … Else … End If Accessing controls on the form Control Properties, Methods, and Events Simple controls: TextBox, Label, CommandButton, Timer ListBox and ComboBox File, Directory, and Drive – example of control interaction 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup PPCC - Introduction to VB6
The Parts of VB6 The Integrated Development Environment This is the VB6 editor/form designer/compiler Visual Studio 6.0 Tools Most of these are for advanced users Sample Projects On-Line Help = MSDN Library See differences between VB6 Editions: http://msdn.microsoft.com/vbasic/previous/vb6/datasheet/feature.aspx 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
Launching VB6 You will find Microsoft Visual Basic 6.0 on your Start > Programs menu "First Choice": New | Existing | Recent See the different choices under each: New Create a new project allows selection of new project from Templates and Wizards Existing Browse for existing VB project files Recent The most recent projects opened in VB6 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
New Project Options Standard EXE Typically used for standard applications Loads with the intrinsic VB6 controls in the toolbox Loads a new project with a single form 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
New Project Options ActiveX EXE or ActiveX DLL Used to create objects used by (other) applications No forms included, creates a single Class module 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
New Project Options ActiveX Control Allows developing your own controls (that can be used on forms in other applications) Loads with the intrinsic VB6 controls in the toolbox Loads a new project with a single form-like UserControl module 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
New Project Options VB Application Wizard Addin Based on user selections, VB creates a skeleton application ready for entering code to handle menu and button events, etc. Addin Creates a project that runs as an add-in under the VB6 IDE 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
New Project Options Data Project Creates a new project that contains a single Form, a DataEnvironment object and a DataReport object This project includes a number of references to support Data Access and Data Binding It also includes several additional controls in the toolbar 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
New Project Options Customization You can add your own project templates and form templates, etc. C:\Program Files\Microsoft Visual Basic\VB98\Template\… If you don’t want the initial dialog to show when you launch VB6, check "Don’t show this dialog in the future". 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
VB 6 Settings 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
VB 6 Settings 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
VB 6 Settings 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
VB 6 Settings 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
The VB6 IDE 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
The VB6 IDE 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
The VB6 IDE The Forms Designer The Toolbox window contains the controls available for use Double click an icon in the Toolbox or Click an icon in the Toolbox and click and drag the sizing handles on the form Release the mouse button Resize control by selecting and click & drag sizing handles 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
The VB6 IDE The VB6 Menu and Toolbar Selection Coordinates Left, Top Width, Height Run, Pause, Stop Application debugging Opens the different windows Examples of custom toolbars Add project, Add "module", Menu editor 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
The VB6 IDE The VB6 Menu and Toolbar Bookmark buttons Indent/Unindent selected block of code Breakpoint Toggle Comment/Uncomment selected block of code Intellisense helpers Intellisense usually kicks in automatically Buttons are not too frequently used 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
The First App – Hello World Open VB6 Create a New Standard EXE project Double-click the form Enter the following code in Sub Form_Load() MsgBox "Hello World" Press F5 or click the button 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
Hello World Variations Using constants and expressions Sub Form_Load() Const WORLD = "World" MsgBox "Hello " & WORLD End Sub 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
Hello World Variations Using Controls and Variables Place a CommandButton on the form Add a Label, TextBox, and another Label to the form Make the Caption for the first label "Name" Double-click the Button Enter the following code in Sub CommandButton1_Click(): Dim sHello as String sHello = "Hello " & Text1.Text Label2.Caption = sHello Press F5 to run, enter a name and click the button 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup
Hello World Variations This is what your form and code should look like: 3/2/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup