310 likes | 495 Views
Introduction to Visual Studio. Visual Basic.Net. Software to Install. Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available from MSDNAA. What is Visual Basic.Net. 4 th Generation Programming Environment / Development Language
E N D
Introduction to Visual Studio Visual Basic.Net
Software to Install • Visual Studio 2005 Professional Edition (Requires Windows XP Pro) • MSDN Library for Visual Studio 2005 Available from MSDNAA
What is Visual Basic.Net • 4th Generation Programming Environment / Development Language • Based on BASIC language • Beginners All-Purpose Symbolic Instructional Code • Most widely used tool for developing Windows Applications • Graphical User Interface (GUI) • Menus, Buttons, Icons to help the user • Full Object-Oriented Programming Language
Visual Studio.NET • A platform that allows the development and deployment of desktop and web applications • Allows user choice of many .NET languages • May program in One of them • May create different parts of application in different languages • Visual Basic • C# (C Sharp) • C++ • J++ • Etc.
Visual Studio.NET • Integrated Development Environment – allows the automation of many of the common programming tasks in one environment • Writing the code • Checking for Syntax (Language) errors • Compiling and Interpreting(Transferring to computer language) • Debugging (Fixing Run-time or Logic Errors) • Running the Application
Creating an Application • Select the “Create Project” option from the “Recent Projects” box on the Start Page
Design Window Toolbox Solution Explorer Properties Window
Creating the Application Step 1: Add a Control to the Form Add a Button to the Form • Look in the Toolbox for the Button Control • Select the Button with the Mouse • Draw a Rectangle Region in the Design Window by holding the mouse button down • Release the mouse button to see your button • (Can also be added by double clicking on the button in the Toolbox)
Creating the Application • Add a Second Button to the Form • Put it in the lower right corner • The project now contains a form with 2 button controls
Setting Control Properties • Properties • Determine the Look and Feel (and sometimes behavior) of a Control • Set through the Properties Window • Properties Set for this Application • Name • Text
Setting Control Properties • Click on the Control in the Design Window • Select the appropriate property in the Properties Window
Control Name • Should be Meaningful • NOT button1, form1, textbox1 • Should begin with a 3 character prefix • Button btn • Label lbl • Textbox txt • Set the name of button1 to btnWelcome • Set the name of button2 to btnExit
Text Property • Determines the visible text on the control • Change the text property • bntWelcome set to “Say Welcome” • btnExit set to “Exit” • Do not need to include the “ “ in your text field • Notice how the buttons now display the new text
Add the Code • To Make the GUI Functional • Open the Code Editor • F7 • Select View Menu then Code option • Double Click on the Control you are writing the code for
Comments • Provide Documentation & Explanations • Begin with a ‘ (followed by an * for readability)
Event Code (Procedures) • GUI programs are Event Driven • Event Procedures respond to events • Writing an Event Procedure • Double click on control from Design Window • Select Control & Event from drop down windows in Code Editor
Select the Control for the Event Procedure • Select the btnWelcome control from the Form Controls List Box
Select the Event for the Event Procedure • Select the Click event from the list of many available events • Buttons have 57 possible events they can respond to
Event Procedure Stub • Beginning of Procedure is created for you • If you create stub by double clicking on control it will create a stub for the most commonly used event
Event Procedure • Write the code that you want executed when the user clicks on the btnWelcome button • Type: MsgBox (“Welcome to Visual Basic”) • Must be contained within the Event Procedure Stub
Writing Visual Basic Code • Not Case Sensitive • Visual Basic will “correct” case issues for you • Keywords are in Blue • Special reserved words • Comments in Green • Problems with Syntax (Language) will be underlined in blue
Create an Event Procedure • Create an Event Procedure for the btnExit button • Have it display “Goodbye” in a MsgBox • Then “End” – this will terminate the program
Switching to Design Window • You can switch between the Design Window and the Code Window (once opened) by clicking on the tabs at the top of the Design and Code Windows • Form1.vb(Design) is the design window • Form1.vb is the Code Window
Running the Application • Click the Run Icon on the Standard Toolbar • Press F5 • This will begin the program • Display the Form/Window • Nothing will happen • Waiting on an Event
Event Driven Program • Click on the “Say Welcome” button • The message box should display • Click on the “Exit” button • The message box should display • The application should terminate
Save the Project • Make sure to save your work • SAVE ALL (not Save Form) • Visual Basic applications are made of several files - Often even several forms