Dani Vainstein1 VBScript Session 1. Dani Vainstein2 Subjets for Session 1 Vbscript fundamentals. Variant subtypes. Variables. Option Explicit statement.

Slides:



Advertisements
Similar presentations
H2K Infosys is business based in Atlanta, Georgia – United States Providing Online IT training services world wide. USA - +1-(770) ,
Advertisements

Introducing JavaScript
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
AE6382 VBA - Excel l VBA is Visual Basic for Applications l The goal is to demonstrate how VBA can be used to leverage the power of Excel u VBA syntax.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
The Web Warrior Guide to Web Design Technologies
Introduction to C Programming
1.
VBA Modules, Functions, Variables, and Constants
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Slide 1 Variables, Constants and Data Types. Slide 2 Variables v Three components define a variable: –Name (memory location) –Type –Information (value)
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
1 Pertemuan 03 Representing Data Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
JavaScript, Third Edition
Introduction to C Programming
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.
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Dani Vainstein1 VBScript Session 9. Dani Vainstein2 What we learn last session? VBScript coding conventions. Code convention usage for constants, variables,
Chapter 3: Using Variables and Constants
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Arrays and 2D Arrays.  A Variable Array stores a set of variables that each have the same name and are all of the same type.  Member/Element – variable.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
Introduction to Programming with RAPTOR
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Dani Vainstein1 VBScript Session 3. Dani Vainstein2 What We learn Last seasson? How to declare arrays. Working with one dimensional a multi- dimensional.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Visual Basic Programming I 56:150 Information System Design.
Programming with Microsoft Visual Basic th Edition
CIVIL AND GEOMATIC ENGINEERING FT Okyere. CIV 257- COMPUTER PROGRAMMING Lecture 3.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Variables in VB.NET. Variables  A storage location in memory (RAM)  Holds data/information while the program is running  These storage locations can.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
INT213 – WEEK 1 ASP tags and comments Variables, Constants, and "Literals" Simple Output.
A variable is a name for a value stored in memory.
VBScript Session 1 Dani Vainstein.
VB Script V B S.
VBScript Session 3.
VBA - Excel VBA is Visual Basic for Applications
VBScript Session 1 IT Professional Academy.
Visual Basic 6 (VB6) Data Types, And Operators
2. Understanding VB Variables
VBScript Session 2 Dani Vainstein.
Chapter 6 Variables What is VBScript?
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
VBScript Session 6 Dani Vainstein.
CIS16 Application Development Programming with Visual Basic
PHP.
VBScript Session 7 Dani Vainstein.
Fundamentals of visual basic
CHAPTER FOUR VARIABLES AND CONSTANTS
VBScript Session 2 Dani Vainstein.
Tutorial 10: Programming with javascript
VBScript Session 1.
Quick Test Professional Training Part 1
Presentation transcript:

Dani Vainstein1 VBScript Session 1

Dani Vainstein2 Subjets for Session 1 Vbscript fundamentals. Variant subtypes. Variables. Option Explicit statement. Keywords. Scope and liftime of variables. Dim, Private and Public statements. Rem statement.

Dani Vainstein3 What is VBScript? A Safe subset of visual basic The VBScript Code is case Insensitive. Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service (IIS).

Dani Vainstein4 Microsoft ® Script Timeline Internet Explorer 3.0 8/96 Version 1.0 Version 2.0 IIS 2 12/96 Internet Explorer 4.0 8/97 Version 3.0 Windows 98 Version 3.1 Version 4.0 Version 5.0 Visual Studio 6 Internet Explorer 5.0 Win NT 5.0 Note: QuickTest uses VBScript 5.6

Dani Vainstein5 Scripting for Specific Platforms VBScript designed to run on multiple platforms that use the ActiveX Scripting Interface. VBA (VB for Applications) More sophisticated customization. Power user focus, natural upgrade, superb integration Visual Basic Best tool for distributed client/Server solutions. Powerful, robust, scalable.

Dani Vainstein6 VBScript Data Types VBScript has only one data type called a Variant. A Variant is a special kind of data type that can contain different kinds of information, depending on how it is used. Because Variant is the only data type in VBScript, it is also the data type returned by all functions in VBScript. At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a number when you use it in a numeric context and as a string when you use it in a string context.

Dani Vainstein7 VBScript Data Types Variant Subtypes Beyond the simple numeric or string classifications, a Variant can make further distinctions about the specific nature of numeric information. For example, you can have numeric information that represents a date or a time. When used with other date or time data, the result is always expressed as a date or a time. You can also have a rich variety of numeric information ranging in size from Boolean values to huge floating-point numbers.

Dani Vainstein8 VBScript Data Types Variant Subtypes DescriptionSubtype Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string variables. Empty Variant intentionally contains no valid data.Null Contains either True or False.Boolean Contains integer in the range 0 to 255.Byte Contains integer in the range -32,768 to 32,767.Integer -922,337,203,685, to 922,337,203,685, Currency Contains integer in the range -2,147,483,648 to 2,147,483,647.Long Contains a single-precision, floating-point number in the range E38 to E-45 for negative values; E-45 to E38 for positive values. Single Contains a double-precision, floating-point number in the range E308 to E-324 for negative values; E-324 to E308 for positive values. Double Contains a number that represents a date between January 1, 100 to December 31, 9999.Date Contains a variable-length string that can be up to approximately 2 billion characters in length.String Contains an object.Object Contains an error number.Error

Dani Vainstein9 Variables A variable is a convenient placeholder that refers to a computer memory location where you can store program information that may change during the time your script is running. For example, you might create a variable called ClickCount to store the number of times a user clicks an object on a particular Web page. you only have to refer to a variable by his name to see or change its value.

Dani Vainstein10 Declaring Variables You declare variables explicitly in your script using the Dim statement, the Public statement, and the Private statement. For example: Dim DegreesFahrenheit You declare multiple variables by separating each variable name with a comma. For example: Dim Top, Bottom, Left, Right

Dani Vainstein11 Declaring Variables You can also declare a variable implicitly by simply using its name in your script. That is not generally a good practice because you could misspell the variable name in one or more places, causing unexpected results when your script is run. For that reason, the Option Explicit statement is available to require explicit declaration of all variables.

Dani Vainstein12 Option Explicit Statement Forces explicit declaration of all variables in a script. If used, the Option Explicit statement must appear in a script before any other statements. When you use the Option Explicit statement, you must explicitly declare all variables using the Dim, Private, Public, or ReDim statements. If you attempt to use an undeclared variable name, an error occurs. Tip Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear.

Dani Vainstein13 Naming Restrictions Must begin with an alphabetic character. Cannot contain an embedded period. Must not exceed 255 characters. Must be unique in the scope in which it is declared. Tip meaningfull prefix to variables to indicate the subtypes i.e iCounter (integer), strName (String), bFlag (Boolean), dteToday (Date)

Dani Vainstein14 VBScript Keywords Empty The Empty keyword is used to indicate an uninitialized variable value. Null The Null keyword is used to indicate that a variable contains no valid data. True The True keyword has a value equal to -1. False The False keyword has a value equal to 0. Nothing The Nothing keyword in VBScript is used to disassociate an object variable from any actual object.

Dani Vainstein15 Scopes and Lifetimes A variable's scope is determined by where you declare it. When you declare a variable within a procedure, only code within that procedure can access or change the value of that variable. If you declare a variable outside a procedure, you make it recognizable to all the procedures in your script. The lifetime of a variable depends on how long it exists. The lifetime of a script-level variable extends from the time it is declared until the time the script is finished running. At procedure level, a variable exists only as long as you are in the procedure. ou can have local variables of the same name in several different procedures because each is recognized only by the procedure in which it is declared.

Dani Vainstein16 Dim Statement Dim varname[([subscripts])][, varname[([subscripts])]]... Declares variables and allocates storage space. Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure. You can also use the Dim statement with empty parentheses to declare a dynamic array. Note When you use the Dim statement in a procedure, you generally put the Dim statement at the beginning of the procedure.

Dani Vainstein17 Private Statement Private varname[([subscripts])][, varname[([subscripts])]]... Declares private variables and allocates storage space. Private statement variables are available only to the script in which they are declared. The following example illustrates use of the Private statement: Private MyNumber ‘ --- Private Variant variable. Private MyArray(9) ‘ --- Private array variable. ‘ --- Multiple Private declarations of Variant variables. Private MyNumber, MyVar, YourNumber

Dani Vainstein18 Public Statement Public varname[([subscripts])][, varname[([subscripts])]]... Declares public variables and allocates storage space. Public statement variables are available to all procedures in all scripts. You can also use the Public statement with empty parentheses to declare a dynamic array. Public MyNumber ‘ --- Public Variant variable. Public MyArray(9) ‘ --- Public array variable. ‘ --- Multiple Public declarations of Variant variables. Public MyNumber, MyVar, YourNumber

Dani Vainstein19 Rem Statement Includes explanatory remarks in a program. Rem Comment ‘ Comment As shown in the syntax section, you can use an apostrophe (') instead of the Rem keyword. If the Rem keyword follows other statements on a line, it must be separated from the statements by a colon. However, when you use an apostrophe, the colon is not required after other statements. MyStr1 = "Hello" : Rem Comment after a statement separated by a colon. MyStr2 = "Goodbye" ' This is also a comment; no colon is needed. Rem Comment on a line with no code; no colon is needed. MyStr1 = "Hello" : Rem Comment after a statement separated by a colon. MyStr2 = "Goodbye" ' This is also a comment; no colon is needed. Rem Comment on a line with no code; no colon is needed.

Dani Vainstein20 Assigning Values to Variables Values are assigned to variables creating an expression as follows: the variable is on the left side of the expression and the value you want to assign to the variable is on the right. For Example : B = 200

Dani Vainstein21 Lab 1.1

Dani Vainstein22 Lab 1.1 Write a small program Declare using Dim 2 variables (a,b) Initialize the variables using a= “ 10 ” and b= “ 5 ” Apply the sum to variable c. Report to QTP the sum of the variables. Use remarks. Tip Tip : Conversion Now declare in the header Option Explicit

Make sure to visit us Tutorials Articles Projects And much more 23