VB scripting basics ppt

powerpoint vbscript and how to use visual basic in powerpoint and scripting language ppt
savi Profile Pic
Published Date:09-03-2017
Your Website URL(Optional)
VB Script V B SVB Scripting Basics  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 V B  VBScript is only supported by Microsoft's browsers S (Internet Explorer)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 SVB Script Variables  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 SRules 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 SDeclaring (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 V - Dim carname B SVB 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 SVB Script Procedures VB Script has two kinds procedures: Ex: 1.) Sub procedure 2.) Function procedure Sub kumar() 1.) Sub procedure: msgbox "kumar" Sub procedure is a series End Sub of statements, enclosed by the Sub kumar() and End Sub statements can perform actions, but does not return a value can take arguments. V B SVBScript Function Procedures  Is a series of statements, enclosed Ex: by the Function and End Function statements. function myfunction() myfunction=Date()  Can perform actions and can end function 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.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 V B execute SIf...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 V msgbox "Have a nice day" B End If End Function S greeting()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 V document.write("Finally Friday") B Case else document.write("Super Saturday") S End SelectVB Script Operators  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 SMath Operators  When you want to perform addition, subtraction, multiplication, and other mathematical operations on numbers and variables use the operators listed below. V B SCom Comp pa ar ris iso on n O Ope per ra ato tor rss  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 SLogical operators  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 SString Concatenation Operator  When you have various strings that you would like to combine into one string use the concatenation operator. V B STHANK YOU Any questions? You can find us at queriesthesisscientist.com V B S