To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.

Slides:



Advertisements
Similar presentations
Working with Intrinsic Controls and ActiveX Controls
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Variables and Constants
Visual Basic Project Files:.VBP file: Project File: a small text file that contains the names of other files in the project, as well as some information.
VBA Modules, Functions, Variables, and Constants
Introducing More Controls Text boxCheck box Option button Command button frame image.
Visual Basic Project Files:.VBP file: Project File: a small text file that contains the names of other files in the project, as well as some information.
Flowchart Start Input weight and height
Text Box controls are used when users are required to type some input (during program execution), or output is displayed on the form (known as the user-
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Developing Software Applications Introduction to Programming Fundamentals Scoping in VB Simple Ifs in VB.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
Introduction to Visual Basic Chulantha Kulasekere.
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
Introduction to Programming Using Visual Basic 6.0
Break Processing Please use speaker notes for additional information!
Let’s get started using Visual Basic!. Private Sub cmdGo_Click... Dim strMessage As String Dim sngSum As Single If IsNumeric(txtNumber1.Text) = False.
Lab 01 Forms in excel Tahani ALdweesh Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
110-G1 Motivation: Within a program, may have to perform the same computation over and over Many programs share the same computation (e.g. sorting) To.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Chapter Two Creating a First Project in Visual Basic.
Visual Basic Programming
Chapter 2 P. 1 Introducing more controls (on the Toolbox) (Fig. 2.1) - Text box - Frame - Option button - Check box - Image Example P. 44 Figure 2.2 Message.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
1 Advanced Computer Programming Lab Calculator Project.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls.
# 1# 1 What is a variable that you create? What is a constant that you create? What is an intrinsic (built-in) constant? What variables are built in?
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Programming with Microsoft Visual Basic th Edition
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
1 CS 106 Computing Fundamentals II Chapter 210 “Adding Controls to User Forms” Herbert G. Mayer, PSU CS Status 7/4/2013 Initial content copied verbatim.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
BBT 10 Visual Basic 03 Enrichment. Tip Before creating any files for your project, first create a new folder Save all of your files in the folder Pieces.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Controlling Program Flow with Decision Structures.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Introduction to Programming Using Visual Basic 6.0 Cheryl Klimack
Adding Code to the Option Button. Open VB 1.Double click the Calculate button and select General from the Object list box. 2.Add the following code to.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3 Variables and Calculations.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Visual Basic Fundamental Concepts
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
Microsoft Visual Basic 2005 BASICS
Visual Basic..
Data Types List Box Combo Box Checkbox Option Box Visual Basic 6.0
Introduction to Programming
Presentation transcript:

To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window will open, with the First and Last lines of the Sub Procedure already in place, by default within VB Follow good coding conventions and Indent all lines between Private Sub and End Sub

Label Caption Property A Label control’s caption size is unlimited. For forms and all other controls that have captions, the limit is 255 characters.

Variables: Memory locations that hold data, that can be changed during project execution (eg: student names will vary as the information for each student is being processed) Constants: Memory locations that hold data that cannot change during execution (eg: however, the college which the students attend (UCC) will remain the same) Variables and Constants

Variables are declared, depending on where they are used and how long their value needs to be retained Variables are locations in the computers memory, which are named by the user Variables store values The values which are assigned to variables can change during project execution (the values they hold varies, hence the name) Variables

Variables have to be declared (the computer must be made aware of their existence) and once they have been declared, the computer allocates them (memory) storage space and assigns this area of memory a name, called an identifier Variables are declared using the DIM statement DIM Variable Name (Identifier) AS Data Type The declaration statements establish the project variables, assign names to the variables, and specify the type of data that the variables will hold The statements are non-executable (they are not executed in the flow of instructions during program execution

Dim stName As STRING (Declares a string variable) Dim iCounter As INTEGER (Declares an integer variable) The reserved word DIM is short for dimension, meaning size Variables can have a number of different data types A variable can only store values which correspond with the data type they are assigned

The data type of a variable indicates what type of information will be stored in the allocated memory space The default data type is variant The advantage of using variant data type is that it is easy, and the variables change their appearance as needed for each situation The disadvantage is that variants are less efficient than the other data types, they require more memory and operate less quickly Data Types

DIM Variable name (Identifier) AS Data Type Dim iYear As Integer Dim stCustName As String can also be declared as: Dim iYear As Integer, stCustName As String Also Specific Characters can be used to represent each of the Data Types Variable Declarations

- String ($) - Integer (%) - Currency - Long Integer (&) - Single Precision (!) - Double Precision (£) Variable Declarations Dim iYear%, stCustName$, Data Types

Text Box controls are used when users are required to type some input (during program execution), or output is displayed on the form (known as the user- interface when the project is running) To display some text in a Text Box during program execution, assign a literal to the Text Property of the Text Box (Does not have a CAPTION Property) txtMessage.Text = “Hello World” Text Boxes

In this example, whatever the user enters into the Text property of the Text Box (txtName) is assigned to the Caption property of the Label (lblName) lblName.Caption = txtName.Text

Frames are used as containers for other controls Groups of Option Buttons or Check Boxes can be placed in frames Using frames to group controls makes the forms easier to understand Set a Frames Caption Property to display the words on the user-interface, on the top edge of the Frame Frames

Allows the user to select or deselect an option In a group of Check Boxes, any number of them may be selected The Value property of a Check Box is set to 0 if unchecked, 1 if checked, or 2 if disabled (greyed) 0 = vbUnchecked 1 = vbChecked Check Boxes

Use only when one Option of a group maybe selected Any Option Buttons placed directly on a Form, function as a Form Group A group of Option Buttons inside a Frame function together as a Frame Group The Value property of an Option Button is set to True if selected, or to False if unselected Option Buttons

Images An Image control holds a picture An Images Picture property can be set to a file with an extension of.BMP,.GIF,.JPG

Writing Windows Apps. with VB The Windows GUI Text boxes Frame Labels Option buttons Check boxes Command buttons Image Picture box

We want to create a program where the height property value of a text box is displayed in the text box, while further printing the contents of the text box onto the form A Practical Example (using Text Boxes)

A variable (X) is declared as an integer Data Type, meaning it can only accept numeric values The Text Box is named BoxContents The Variable X is assigned the value of the Height property of BoxContents (Text Box) The Text property of BoxContents consists of a literal and the value of the variable X The Text in BoxContents is also printed on the form

Before Project Execution During Project Execution

Additional Instructions Make the Text Box blank once the contents have been printed Notify the user that the Text Box is blank Add this Code to the End of the Sub-Procedure BoxContents.Text =“” ‘Empties whatever is in the text box Print “The Text Box (BoxContents) is now blank” ‘Prints this message on the form