Development of Internet Application 1501CT - Sara Almudauh

Slides:



Advertisements
Similar presentations
1 VBScript Session What we learn last session?
Advertisements

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
1 Today: Introduction to ASP- Part 1 Explain the client/server architecture Explain Web-based client/server applications Understand the essentials of Active.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
CIS 375—Web App Dev II VBScript. 2 Introduction to VBScript VBScript is a light version of MS’s ____________. Example: document.write("Hello from VBScript!")
Basics of ASP.NET. 2 © UW Business School, University of Washington 2004 Outline Installing ASP.NET and Web Matrix Data Types Branching Structure Procedures.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Introduction to Active Server Pages
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Why to Create a Procedure
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
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.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
Compunet Corporation1 Programming with Visual Basic.NET While, Do and For – Next Loops Week 5 Tariq Ibn Aziz.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
VBScript. Introduction Visual Basic scripting language is client side scripting language. It is developed by Microsoft VBScript is subset of VB language.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
ASP-5-1 ASP Control Structures Colorado Technical University IT420 Tim Peterson.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Visual Basic Programming I 56:150 Information System Design.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
VBScript Conditional Statements. Conditional Statements Very often when you write code, you want to perform different actions for different decisions.
Introduction to Programming Lecture 2 Msury Mahunnah, Department of Informatics, Tallinn University of Technology.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
Controlling Program Flow with Decision Structures.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
CSET 3250 Client-Side Scripting VBScript : Operators, Control Structures, Procedures and Functions.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
ASP Mr. Baha & Dr.Husam Osta  What is ASP?  Internet Information Services  How Does ASP Differ from HTML?  What can ASP do for you?  ASP Basic.
By “FlyingBono” 2009_02By FlyingBono.  ASP code is embedded in HTML using tags.  A ASP scripting block always starts with.  Server scripts are executed.
INT213 – WEEK 1 ASP tags and comments Variables, Constants, and "Literals" Simple Output.
Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.
Lecture 6 Sara Almudauh ASP.NET Part 1 Development of Internet Application 1501CT - Sara Almudauh.
Introduction to Programming Lecture 2
VB Script V B S.
VBA - Excel VBA is Visual Basic for Applications
VBScript Session 1 IT Professional Academy.
Visual Basic 6 (VB6) Data Types, And Operators
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Problem Solving and Control Statements: Part 2
Control Structures: Part 2
My First Web Page document.write("" + Date() + ""); To insert.
JavaScript Syntax and Semantics
Method.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
2. Understanding VB Variables
The structure of computer programs
Arrays, For loop While loop Do while loop
Control Structures: Part 1
Chapter 6 Variables What is VBScript?
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Logical Operations In Matlab.
Objectives In this chapter, you will:
ASP control structure BRANCHING STATEMENTS
Quick Test Professional Training Part 1
Introduction to Computer Programming IT-104
Presentation transcript:

Development of Internet Application 1501CT - Sara Almudauh VBScript Part 1 Lecture 6 Sara Almudauh Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh VBScript is a Microsoft scripting language. VBScript is a light version of Microsoft's programming language Visual Basic. VBScript is the default scripting language in ASP (Active Server Pages). Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh VBScript on a Server When VBScript is used with ASP, the statement response.write() produces output. <html> <body> <%response.write("This is my first VBScript")%> </body> </html> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh VBScript Variables A variable can have a short name, like x, or a more descriptive name, like carname. Rules for VBScript variable names: Must begin with a letter  Cannot contain a period (.) Cannot exceed 255 characters In VBScript, all variables are of type variant, that can store different types of data. Development of Internet Application 1501CT - Sara Almudauh

Declaring (Creating) VBScript Variables You can declare VBScript variables with the Dim, Public or the Private statement. Like this: Dim x Dim carname Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Example <!DOCTYPE html> <html> <body> <% Dim firstname firstname=“Sara" response.write(firstname) response.write("<br>") firstname=“Ahmed" response.write(firstname) %> </body> </html> Sara Ahmed Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Example <!DOCTYPE html> <html> <body> <% Dim firstname firstname=“Sara” response.write(“your first name is :”&firstname) %> </body> </html> your first name is : Sara Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh VBScript Procedures VBScript has two kinds procedures: Sub procedure Function procedure Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Sub Procedures A 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 Sub mysub()   some statements End Sub Sub mysub(argument1,argument2)   some statements End Sub or Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Example <!DOCTYPE html> <html> <body> <% Sub mysub()    response.write("I was written by a sub procedure") End Sub response.write("I was written by the script<br>") Call mysub() %> </body> </html> I was written by the script I was written by a sub procedure Development of Internet Application 1501CT - Sara Almudauh

VBScript Function Procedures A Function procedure: 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 Development of Internet Application 1501CT - Sara Almudauh

VBScript Function Procedures Function myfunction()   some statements   myfunction=some value End Function or Function myfunction(argument1,argument2)   some statements   myfunction=some value End Function Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Example <!DOCTYPE html> <html> <body> <% Function myfunction() myfunction=Date() End Function response.write("Today's date: ") response.write(myfunction()) %>   <p>A Function procedure can return a result.</p> </body> </html> Today's date: 2/22/2016 A Function procedure can return a result. Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Calling a Procedure <!DOCTYPE html> <html> <body> <% Function myfunction(a,b) myfunction=a+b End Function response.write(myfunction(5,9)) %> </body> </html> 14 Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Calling a Procedure When you call a procedure you can use the Call statement, like this: Call MyProc(argument) Or, you can omit the Call statement, like this: MyProc argument Development of Internet Application 1501CT - Sara Almudauh

VBScript Conditional Statements 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 Development of Internet Application 1501CT - Sara Almudauh

VBScript Conditional Statements If you want to execute only one statement when a condition is true, you can write the code on one line: If i=10 Then response.write("Hello") If you want to execute more than one statement when a condition is true, you must put each statement on separate lines, and end the statement with the keyword "End If": If i=10 Then response.write("Hello") i = i+1 End If Development of Internet Application 1501CT - Sara Almudauh

VBScript Conditional Statements There is no ..Else.. in the example above either. You just tell the code to perform multiple actions if the condition is true. If you want to execute a statement if a condition is true and execute another statement if the condition is not true, you must add the "Else" keyword: <!DOCTYPE html> <html> <body> <% i=hour(time) If i <  10 Then   response.write("Good morning!") Else   response.write("Have a nice day!") End If %> </body> </html> Good morning! Development of Internet Application 1501CT - Sara Almudauh

VBScript Conditional Statements If...Then...ElseIf You can use the If...Then...ElseIf statement if you want to select one of many blocks of code to execute: <html> <body> <% i=hour(time) If i = 10 Then       response.write("Just started...!") ElseIf i = 11 Then       response.write("Hungry!") ElseIf i = 12 Then       response.write("Ah, lunch-time!") ElseIf i = 16 Then       response.write("Time to go home!") Else       response.write("Unknown") End If %> </body> </html> Good morning! Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Select Case You can also use the "Select Case" statement if you want to select one of many blocks of code to execute: d=weekday(Date) Select Case d    Case 1      response.write("Sleepy Sunday")    Case 2      response.write("Monday again!")    Case 3      response.write("Just Tuesday!")    Case 4      response.write("Wednesday!")    Case 5      response.write("Thursday...")    Case 6      response.write("Finally Friday!")    Case Else      response.write("Super Saturday!!!!") End Select %> Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh VBScript Looping In VBScript we have four looping statements: For...Next statement - runs code a specified number of times For Each...Next statement - runs code for each item in a collection or each element of an array Do...Loop statement - loops while or until a condition is true While...Wend statement - Do not use it - use the Do...Loop statement instead Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh For...Next Loop Use the For...Next statement to run a block of code a specified number of times. The For statement specifies the counter variable (i), and its start and end values. The Next statement increases the counter variable (i) by one. <html> <body> <% For i = 0 To 5   response.write("The number is " & i & "<br />") Next %> </body> </html> The number is 0 The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Do...Loop If you don't know how many repetitions you want, use a Do...Loop statement. The Do...Loop statement repeats a block of code while a condition is true, or until a condition becomes true. Repeat Code While a Condition is True You use the While keyword to check a condition in a Do...Loop statement. Do While i>10   some code Loop Development of Internet Application 1501CT - Sara Almudauh

Read more about Loops in VB http://www.w3schools.com/asp/vbscript_looping.asp http://www.tutorialspoint.com/vbscript/ http://www.pickatutorial.com/tutorial/vbscript/first_vbscript_code.htm Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh VBScript Examples Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Display Date and Time <!DOCTYPE html> <html> <body> <% response.write("Today's date is " & Date()) response.write("<br>") response.write("The time is " & Time()) %> </body> </html> Today's date is 2/22/2016 The time is 2:30:17 PM Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Display Days <!DOCTYPE html> <html> <body> <p>VBScripts' function <b>WeekdayName</b> is used to get a weekday:</p> <% response.write("<p>") response.write(WeekDayName(1)) response.write("<br>") response.write(WeekDayName(2)) response.write("</p><p>") response.write("Get the abbreviated name of a weekday:") response.write("<br>") response.write(WeekDayName(1,True)) response.write("<br>") response.write(WeekDayName(2,True)) response.write("</p><p>") response.write("Get the current weekday:") response.write("<br>") response.write(WeekdayName(weekday(Date))) response.write("<br>") response.write(WeekdayName(weekday(Date), True)) response.write("</p>") %> </body> </html> VBScripts' function WeekdayName is used to get a weekday: Sunday Monday Get the abbreviated name of a weekday: Sun Mon Get the current weekday: Monday Mon Development of Internet Application 1501CT - Sara Almudauh

Display the current month and day <!DOCTYPE html> <html> <body> <% response.write("Today's day is " & WeekdayName(Weekday(Date))) response.write("<br>") response.write("The month is " & MonthName(Month(Date))) %> </body> </html> Today's day is Monday The month is February Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh More Examples http://www.w3schools.com/asp/vbscript_examples.asp Development of Internet Application 1501CT - Sara Almudauh

Development of Internet Application 1501CT - Sara Almudauh Questions !!  Development of Internet Application 1501CT - Sara Almudauh