Download presentation
Presentation is loading. Please wait.
1
VB Script V B S
2
VB Scripting Basics B S V
VBScript stands for Visual Basic Scripting, is a scripting language was launched by Microsoft in1996. VB Scripting language is a lightweight programming language. VBScript can be used to write both client-side and server-side scripting. VBScript is a light version of Microsoft's programming language Visual Basic VBScript is only supported by Microsoft's browsers (Internet Explorer) V B S
3
Data Types VBScript supports only one data type called ‘Variant’. The variant data type is a special kind of data type that can contain different kinds of information. It is the default data type returned by all functions in VB Script. A variant behaves as a number when it is used in a numeric context and as a string when used in a string context. V B S
4
VB Script Variables B S V
A variable is a "container" /Placeholder that refers to a memory location, that stores program information that may change at run time. As with algebra, VBScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. V B S
5
Rules for VBScript variable names
Must begin with a letter Cannot contain a period (.) Cannot exceed 255 characters In VB Script, all variables are variant data type, that can store different types of data. V B S
6
Declaring (Creating) VBScript Variables
Creating variables in VBScript is most often referred to as "declaring" variables. You can declare VBScript variables with the Dim, Public or the Private statement. Like this: - Dim x - Dim carname V B S
7
VB Script Array Variables
An array variable is used to store multiple values in a single variable. In the following example, an array containing 3 elements is declared: Ex: Dim names(2) The number shown in the parentheses is 2. We start at zero so this array contains 3 elements. This is a fixed-size array. You assign data to each of the elements of the array like this: names(0)="Tove“ names(1)="Jani" names(2)="Stale" V B S
8
VB Script has two kinds procedures:
VB Script Procedures Ex: Sub kumar() msgbox "kumar" End Sub kumar() VB Script has two kinds procedures: 1.) Sub procedure 2.) Function procedure 1.) Sub procedure: Sub procedure is a series of statements, enclosed by the Sub and End Sub statements can perform actions, but does not return a value can take arguments. V B S
9
VBScript Function Procedures
Ex: function myfunction() myfunction=Date() end function Is a series of statements, enclosed by the Function and End Function statements. Can perform actions and can return a value. Can take arguments that are passed to it by a calling procedure. Without arguments, must include an empty set of parentheses (). Returns a value by assigning a value to its name.
10
Conditional Statements
Conditional statements are used to perform different actions for different decisions. In VBScript we have four conditional statements: If statement - executes a set of code when a condition is true If...Then...Else statement - select one of two sets of lines to execute If...Then...ElseIf statement - select one of many sets of lines to execute Select Case statement - select one of many sets of lines to execute V B S
11
If...Then...Else Use the If...Then...Else statement if you want to Execute some code if a condition is true Select one of two blocks of code to execute If you want to execute only one statement when a condition is true, you can write the code on one line: Ex: Function greeting() i=hour(time) msgbox i If i < 10 Then msgbox "Good morning!" Else msgbox "Have a nice day!" End If End Function greeting() V B S
12
Select Case You can also use the "Select Case" statement if you want to select one of many blocks of code to execute: Select Case d Case 1 msgbox "Sleepy Sunday" Case 2 .write("Monday again!") Case 3 document.write("Just Tuesday!") Case 4 document.write("Wednesday!") Case 5 document.write("Thursday...") Case 6 document.write("Finally Friday!") Case else document.write("Super Saturday!!!!") End Select V B S
13
VB Script Operators B S V
Operators are used to "do operations" or manipulate variables and values. For example, addition is an example of a mathematical operator and concatenation is an example of a string operator. The plus sign "+" is the operator used in programming language to represent this mathematical addition operation. V B S
14
Math Operators When you want to perform addition, subtraction, multiplication, and other mathematical operations on numbers and variables use the operators listed below. V B S
15
B S Comparison Operators Comparison Operators V
When you want to compare two numbers to see which is bigger, if they're equal, or some other type of relationship use the comparison operators listed below. Common uses of comparison operators are within conditional statements like an If Statement or the condition check in a While Loop. V B S
16
Logical operators B S manipulate and create logical
Logic operators are used to manipulate and create logical statements. For example if you wanted a variable shoeSize to be equal to 10 or 11 then you would do something like: V B S
17
String Concatenation Operator
When you have various strings that you would like to combine into one string use the concatenation operator. V B S
18
THANK YOU ! B S Any questions?
You can find us at V B S
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.