1 / 21

CN2180 Chapter 3

CN2180 Chapter 3. Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP. Agenda. VBScript Basics Assignment Quiz. VBScript Statements. Table 3.1 on page 51 - 52. VBScript Syntax Rules. By default, all VBScript statements must fit on one line.

myrna
Download Presentation

CN2180 Chapter 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CN2180Chapter 3 Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP

  2. Agenda • VBScript Basics • Assignment • Quiz

  3. VBScript Statements • Table 3.1 on page 51 - 52

  4. VBScript Syntax Rules • By default, all VBScript statements must fit on one line. • _ (Continuation) character is an exception to have more than one line statement • : (Colon) character is used to put more than one statement on a single line

  5. VBScript Syntax Rules (Cont.) • Option Explicit : • To make sure that you declare variables • To troubleshoot by generating errors to highlight mistakes if variable names are mistyped later in the script • The text book is NOT properly stated. • See page 52 for more information

  6. Reserved Words • Table 3.2 on page 54

  7. Adding Comments • Two ways to add comments • Rem (Remark) • ‘ • A good practice example on page 55

  8. VBScript Object Model • Besides WSH Core Object Model, there are Built-in objects as well • Table 3.3 on page 56 • See chapter 11.

  9. VBScript Run-Time Objects • To interface with the windows resources • See Table 3.4 on page 57

  10. VBScript Run-Time Objects • FileSystemObject object is needed. • You can check the existence of files and folder before attempting to work with them • Create and delete files and folders. • See page 58.

  11. VBScript Run-Time Objects • Table 3.5 on Page 58 provides a complete list of VBScript run-time properties. • Table 3.6 on Page 60provides a list of VBScript run-time method.

  12. VBScript Run-Time Objects • See code on page 61.

  13. Built-in VBScript Functions • There are a lot of built-in function • InputBox() • MsgBox() • Sqr() • See Appendix D on page 417. • See code on page 64.

  14. Displaying Script Output • There are 4 options to display output • Echo() • Popup() • InputBox() • MsgBox()

  15. Echo() Method • Wscript.Echo [Arg1] [,Args2] …

  16. Popup() Method Set WshShl = Wscript.CreateObject(“Wscript.Shell”) • Two syntax of Popup() Response = Wscript.Popup(StrText,[Time],[TitleBarMsg],[DialogSettings]) Wscript.PopupStrText,[Time],[TitleBarMsg],[DialogSettings] • See Table 3.8 and 3.9 for Dialog Settings • Table 3.10 lists the range of values of Response

  17. InputBox() Function Response = InputBox (StrText[, TitleBarMsg][, default][, xpos][, ypos][, helpfile, context])

  18. MsgBox() Function • MsgBox (TextMsg[, buttons][, TitleBarMsg][, helpfile, context]) • See Table 3.11 and 3.12 for buttons option on page 70 • See Table 3.13 for possible outcome on page 71

  19. SendKeys() method • This method is used to send keystrokes to currently active Windows application • See Table 3.14 on page 73 and Table 3.15 on page 74

  20. Let’s the game begin! • Page 74

  21. Assignment • Challenges #1 : Modified the script to solve the equation 10 – 5 * 3 / Sqr(10) – 1 • Challenges #2 : Show input box to ask for your name. Then use script to open notepad and type “My name is “ & your name

More Related