Download presentation
Presentation is loading. Please wait.
1
CIS 375—Web App Dev II VBScript
2
2 Introduction to VBScript VBScript is a light version of MS’s ____________. Example: document.write("Hello from VBScript!") Handling older browsers: <!– some statements -->
3
3 VBScript…Where To VBScript ___________ are usually located in the head section of a web page. VBScript code can also be located in the body section. some statements some statements
4
4 Variables Use “option explicit” to force yourself to declare variables before using them: option explicit dim name name=“Richard Johnson” A VBScript “procedure” is like a JavaScript “_________.” Procedure variables have _____ scope. An array with _______ elements: dim names (2) Assigning a value: names(0)=“John Doe” A two-dimensional array with 5 rows and 7 columns: dim table (5, 7)
5
5 Procedures The Sub procedure can perform actions, but does not _______ a value. sub mySub() msgbox("This is a sub procedure") end sub Calling a Sub procedure: call mySub() The Function procedure can return a value. function myFunction() myFunction = "BLUE" end function Calling a Function: document.write(“The sky is “ & myFunction())
6
6 If…Then…Elseif if payment="Cash" then msgbox "You are going to pay cash!" elseif payment="Visa" then msgbox "You are going to pay with Visa." elseif payment="AmEx" then msgbox "You are going to pay with American Express." else msgbox "Unknown method of payment." end If
7
7 Select Case select case payment case "Cash" msgbox "You are going to pay cash" case "Visa" msgbox "You are going to pay with visa" case "AmEx" msgbox "You are going to pay with American Express" case Else msgbox "Unknown method of payment" end select
8
8 For…Next for i = 0 to 6 Step 2 document.write("The number is " & i & " ") next For Each…Next dim names(2) names(0)="Tove" names(1)="Jani" names(2)="Hege" For Each x in names document.write(x & " ") Next
9
9 Do…While i=0 do while i < 10 document.write(i & " ") i=i+1 loop Do Until i=10 i=i-1 If i<10 Then Exit Do Loop Exit a Do…Loop
10
10 Examples Look at many other VBScript examplesexamples
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.