You are on page 1of 6

Student Name

Class

Date

VBScript IPO Lab Key


Copy your NameAge.vbs program from NotePad++ and paste it into the space provided below:. ' VBScript: NameAge.vbs ' Written by: Student Name ' Date: Today's Date ' Class: COMP230 ' Professor: Professor Name ' ============================================== 'Create name and age variables name = "" ageStr = "" ' Prompt User for Name and Age WScript.StdOut.Write("Pleasse Enter your Full Name .............. ") name = WScript.StdIn.ReadLine() WScript.StdOut.WriteLine() 'Skip 1 line WScript.StdOut.Write("Please Enter your age ..................... ") ageStr = Wscript.StdIn.ReadLine() ' Calculate Age+10 and assign to ageStr10 ageStr10 = CStr( CInt(ageStr)+10 ) ' Display Name and Age Values WScript.StdOut.WriteBlankLines(2) 'Skip 2 lines WScript.StdOut.WriteLine("Your Name is " & vbTab & vbTab & name) WScript.StdOut.WriteLine("Your Age is " & vbTab & vbTab & ageStr) WScript.StdOut.WriteLine(vbCrLf & "Your Age in 10 years is ...... " & _ ageStr10 & vbCrLf) WScript.StdOut.WriteLine("End of Program")

COMP230_W2_IPO_evKey.docx

Revision Date: 1207

Capture the NameAge.vbs Run from the console window and copy it into the space provided below:

C:\Scripts>cscript NameAge.vbs Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. Please Enter your Full Name .............. John Morgan Please Enter your age .................... 55

Your name is Your age is

John Morgan 55

Your Age in 10 years will be ...... 65 End of Program

COMP230_W2_IPO_evKey.docx

Revision Date: 1207

Copy your PopUpWindow.vbs program from NotePad++ and paste it into the space provided below: ' VBScript: PopUpWindow.vbs ' Written by: Student Name ' Date: Today's Date ' Class: COMP230 ' Professor: Professor Name ' ============================================== 'Create name and age variables name = "John Doe" ageStr = "50" ' Calculate Age+10 and assign to ageStr10 ageStr10 = CStr( CInt(ageStr)+10 ) ' Build output as a single string msgStr msgStr = "Your name is " & vbTab & vbTab & name & _ vbCrLf & "Your age is " & vbTab & vbTab & ageStr & _ vbCrLf & vbCrLf & "Your Age in 10 years will be ...... " & _ ageStr10 & vbCrLf & vbCrLf & "End of Program" 'One Echo Statement for all output WScript.Echo msgStr

COMP230_W2_IPO_evKey.docx

Revision Date: 1207

Capture the PopUpWindow.vbs Run (using <Alt><PrtSc> to capture the PopUp Window on the desktop) and copy it into the space provided below:

COMP230_W2_IPO_evKey.docx

Revision Date: 1207

Copy your CmdArgs.vbs program from NotePad++ and paste it into the space provided below: ' VBScript: CmdArgs.vbs ' Written by: Student Name ' Date: Today's Date ' Class: COMP230 ' Professor: Professor Name ' ============================================== ' Check for Command Line Arguments Set args = WScript.Arguments If args.Count < 2 then WScript.Echo "You must enter the name and age as Command Line Arguments!!" WScript.Sleep(5000) WScript.Quit end If ' Assign name and age variables to Cmd Line Args name = args.item(0) ageStr = args.item(1) ' Calculate Age+10 and assign to ageStr10 ageStr10 = CStr( CInt(ageStr)+10 ) ' Build output as a single string msgStr msgStr = "Your name is " & vbTab & vbTab & name & _ vbCrLf & "Your age is " & vbTab & vbTab & ageStr & _ vbCrLf & vbCrLf & "Your Age in 10 years will be ...... " & _ ageStr10 & vbCrLf & vbCrLf & "End of Program" 'One Echo Statement for all output WScript.Echo msgStr

COMP230_W2_IPO_evKey.docx

Revision Date: 1207

Capture the two CmdArgs.vbs console Runs (one without arguments and one using your name and age as arguments) and copy the runs into the space provided below:

C:\Scripts>cscript CmdArgs.vbs Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. You must enter the name and age as Command Line Arguments!!

C:\Scripts>cscript CmdArgs.vbs "Jane Doe" 35 Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. Your name is Your age is Jane Doe 35

Your Age in 10 years will be ...... 45 End of Program

COMP230_W2_IPO_evKey.docx

Revision Date: 1207

You might also like