Documents

1353581043 Vb Script Help

Description
vb script help
Categories
Published
of 275
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
  Using the VBScript Reference QuickTest's Expert View is a VBScript Editor. Therefore, in addition to entering test object statements and other testing-oriented functions, you can manually enter any valid Microsoft VBScript statement. You canalso use the Step Generator from the Expert View or from the Keyword View to insert many VBScript statements.To assist you, the QuickTest Professional Help includes Microsoft's Visual Basic Scripting documentation. The included documentation is composed of three sections, each of which contain information that can berelevant when working with QuickTest: VBScript . Includes a user's guide and a thorough reference of objects, methods, properties, functions, and other elements that can be used when writing VBScript scripts. Script Runtime . Describes the Dictionary object, FileSystemObject object, and the Script Encoder tool. Windows Script Host . Includes overview information and a reference for working with the Microsoft Windows Script Host tool.Note: Although some of the topics in these three sections may contain both VBScript and JScript information or examples, QuickTest supports only VBScript. Do not attempt to use JScript examples from theVBScript reference in QuickTest. Using the Microsoft Visual Basic Scripting Documentation All Help topics under the  VBScript Reference > VBScript, VBScript Reference > Script Runtime , and  VBScript Reference > Windows Script Host  sections are from Microsoft. These Help files were notprepared by HP and HP is not responsible for their content. These help files were taken directly from Microsoft's  Script56.chm  help file, downloaded fromhttp://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp.In accordance with section 1d of the  End-User License Agreement for Microsoft Software , provided with Microsoft Windows Script 5.6, only unmodified portions of the documentation from the Script56.CHM helpfile relating to VBScript have been included herein under the  VBScript Reference  heading.The information under the  VBScript Reference  heading may contain errors, problems, or other limitations. HP makes no representations whatsoever as to the accuracy, adequacy, reliability, currentness,completeness, suitability or applicability of the information under the VBScript Reference heading. HP is not responsible for any damages, including the loss of time, which may result from using the information inthe help files under the  VBScript Reference heading.The content under the  VBScript Reference  heading may contain links to Internet sites. Such links may not provide access to the intended site, or any site. Further, such links are not endorsements of any products orservices in such sites, and no information in such site has been endorsed by HP. SOME OF THESE HELP PAGES OR INTERNET SITES WILL MAKE REFERENCE TO JSCRIPT, HOWEVER THESEREFERENCES ARE NOT APPLICABLE TO QUICKTEST PROFESSIONAL BECAUSE QUICKTEST PROFESSIONAL DOES NOT SUPPORT JSCRIPT .Windows®,Microsoft®,JScript®,and Visual Basic®are registered trademarks of Microsoft Corporation in the United States and other countries. There is no relationship between Microsoft Corporation and HP.The views expressed in the Help topics under the  VBScript Reference  heading are solely those of Microsoft Corporation.The following notice applies to the Microsoft VBScript Help topics:©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 VBScript VBScipt User's GuideVBScript Langauge Reference©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 VBScript User's Guide What Is VBScript?Adding VBScript Code to an HTML Page VBScript Fundamentals VBScript Data TypesVBScript VariablesVBScript ConstantsVBScript OperatorsUsing Conditional StatementsLooping Through CodeVBScript ProceduresVBScript Coding Conventions©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 What Is VBScript? Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet InformationService. VBScript Reference©Copyright 2009 Mercury Interactive (Israel) Ltd. VisualBasicScriptingEditiVisualBasicScriptingEditiVisualBasicScriptingEditi  Easy to Use and Learn If you already know Visual Basic or Visual Basic for Applications (VBA), VBScript will be very familiar. Even if you do not know Visual Basic, once you learn VBScript, you are on your way to programming with the wholefamily of Visual Basic languages. Although you can learn about VBScript in just these few Web pages, they do not teach you how to program. To learn programming, take a look at  Step by Step  books available from MicrosoftPress. Windows Script VBScript talks to host applications using Windows Script. With Windows Script, browsers and other host applications do not require special integration code for each scripting component. Windows Script enables a host tocompile scripts, obtain and call entry points, and manage the namespace available to the developer. With Windows Script, language vendors can create standard language run times for scripting. Microsoft will provide run-timesupport for VBScript. Microsoft is working with various Internet groups to define the Windows Script standard so that scripting engines can be interchangeable. Windows Script is used in Microsoft®Internet Explorer and inMicrosoft®Internet Information Service. VBScript in Other Applications and Browsers As a developer, you can license VBScript source implementation at no charge for use in your products. Microsoft provides binary implementations of VBScript for the 32-bit Windows®API, the 16-bit Windows API, and theMacintosh®.VBScript is integrated with World Wide Web browsers. VBScript and Windows Script can also be used as a general scripting language in other applications.©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 Adding VBScript Code to an HTML Page You can use the SCRIPT element to add VBScript code to an HTML page. The <SCRIPT> Tag VBScript code is written within paired <SCRIPT> tags. For example, a procedure to test a delivery date might appear as follows: <SCRIPT LANGUAGE= VBScript ><!--Function CanDeliver(Dt) CanDeliver = (CDate(Dt)-Now()) > 2 End Function--></SCRIPT> Beginning and ending <SCRIPT> tags surround the code. The LANGUAGE attribute indicates the scripting language. You must specify the language because browsers can use other scripting languages. Notice that the CanDeliver  function is embedded in comment tags (<!  —  and  —  >).This prevents browsers that don't understand the <SCRIPT> tag from displaying the code.Since the example is a general function  —  it is not tied to any particular form control  —  you can include it in the HEAD section of the page: <HTML><HEAD><TITLE>Place Your Order</TITLE><SCRIPT LANGUAGE= VBScript ><!--Function CanDeliver(Dt) CanDeliver = (CDate(Dt)-Now()) > 2 End Function--></SCRIPT></HEAD><BODY>... You can use SCRIPT blocks anywhere in an HTML page. You can put them in both the BODY and HEAD sections. However, you will probably want to put all general-purpose scripting code in the HEAD section in order tokeep all the code together. Keeping your code in the HEAD section ensures that all code is read and decoded before it is called from within the BODY section.One notable exception to this rule is that you may want to provide inline scripting code within forms to respond to the events of objects in your form. For example, you can embed scripting code to respond to a button click in aform: <HTML><HEAD><TITLE>Test Button Events</TITLE></HEAD><BODY><FORM NAME= Form1 > <INPUT TYPE= Button NAME= Button1 VALUE= Click > <SCRIPT FOR= Button1 EVENT= onClick LANGUAGE= VBScript > MsgBox Button Pressed!  </SCRIPT></FORM></BODY></HTML> Most of your code will appear in either  Sub  or  Function  procedures and will be called only when specified by your code. However, you can write VBScript code outside procedures, but still within a SCRIPT block. This code isexecuted only once, when the HTML page loads. This allows you to initialize data or dynamically change the look of your Web page when it loads.©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 VBScript Features not in Visual Basic for Applications The following table lists VBScript features not in Visual Basic for Applications.VisualBasicScriptingEditiVisualBasicScriptingEditi Category Feature/Keyword DeclarationsClassMiscellaneousEvalExecuteObjectsRegExpScript Engine IdentificationScriptEngineScriptEngineBuildVersionScriptEngineMajorVersionScriptEngineMinorVersion  ©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 Visual Basic for Applications Features Not In VBScript The following table lists Visual Basic for Applications Features not in VBScript.©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 VBScript Fundamentals VBScript Data TypesVBScript VariablesVBScript ConstantsVBScript OperatorsUsing Conditional StatementsLooping Through CodeVBScript ProceduresVBScript Coding Conventions©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 A Simple VBScript Page A Simple Page With Microsoft®Internet Explorer, you can view thepage produced by the following HTML code. If you click the button on the page, you see VBScript in action. <HTML><HEAD><TITLE>A Simple First Page</TITLE><SCRIPT LANGUAGE= VBScript ><!--Sub Button1_OnClick MsgBox Mirabile visu. End Sub--></SCRIPT></HEAD> VisualBasicScriptingEditi Category Omitted Feature/Keyword Array HandlingOption BaseDeclaring arrays with lower bound <> 0CollectionAdd, Count, Item, RemoveAccess to collections using ! characterConditional Compilation#Const#If...Then...#ElseControl FlowDoEventsGoSub...Return, GoToOn Error GoToOn...GoSub, On...GoToLine numbers, Line labelsConversionCVar, CVDateStr, ValData TypesAll intrinsic data types except VariantType...End TypeDate/TimeDate statement, Time statementDDELinkExecute, LinkPoke, LinkRequest, LinkSendDebuggingDebug.PrintEnd, StopDeclarationDeclare (for declaring DLLs)OptionalParamArrayStaticError HandlingErlErrorResume, Resume NextFile Input/OutputAll traditional Basic file I/OFinancialAll financial functionsObject ManipulationTypeOf ObjectsClipboardCollectionOperatorsLikeOptionsDef  type Option BaseOption CompareOption Private ModuleSelect CaseExpressions containing  Is  keyword or any comparison operatorsExpressions containing a range of values using the  To  keyword.StringsFixed-length stringsLSet, RSetMid StatementStrConvUsing ObjectsCollection access using !VisualBasicScriptingEditiVisualBasicScriptingEditi  <BODY><H3>A Simple First Page</H3><HR><FORM><INPUT NAME= Button1 TYPE= BUTTON VALUE= Click Here ></FORM></BODY></HTML> The result is a little underwhelming: a dialog box displays a Latin phrase ( Wonderful to behold ). However, there's quite a bit going on.When Internet Explorer reads the page, it finds the <SCRIPT> tags, recognizes there is a piece of VBScript code, and saves the code. When you click the button, Internet Explorer makes the connection between the button andthe code, and runs the procedure.The  Sub  procedure in the <SCRIPT> tags is an event procedure. There are two parts to the procedure name: the name of the button, Button1  (from the NAME attribute in the <INPUT> tag), and an event name, OnClick . Thetwo names are joined by an underscore(_). Any time the button is clicked, Internet Explorer looks for and runs the corresponding event procedure, Button1_OnClick .Internet Explorer defines the events available for form controls in the Internet Explorer Scripting Object Model documentation, which can be found on the Microsoft®Web site (http://www.microsoft.com).Pages can use combinations of controls and procedures, too.VBScript and Forms shows some simple interactions between controls. Other Ways to Attach Code to Events Although the preceding way is probably the simplest and most general, you can attach VBScript code to events in two other ways. Internet Explorer allows you to add short sections of inline code in the tag defining the control.For example, the following <INPUT> tag performs the same action as the previous code example when you click the button: <INPUT NAME= Button1 TYPE= BUTTON  VALUE= Click Here OnClick='MsgBox Mirabile visu. '> Notice that the function call itself is enclosed in single quotation marks, and the string for the  MsgBox  function is enclosed in double quotation marks. You can use multiple statements as long as you separate the statements withcolons (:).You can also write a <SCRIPT> tag so that it applies only to a particular event for a specific control: <SCRIPT LANGUAGE= VBScript EVENT= OnClick FOR= Button1 ><!--MsgBox Mirabile visu. --></SCRIPT> Because the <SCRIPT> tag already specifies the event and the control, you don't use  Sub  and  End Sub  statements.©2001 Microsoft Corporation. All rights reserved.Build: Topic Version 5.6.9309.1546 VBScript Features The following table is a list of VBScript features.VisualBasicScriptingEditi Category Keywords Array handlingArrayDim,Private,Public,ReDim IsArrayEraseLBound,UBoundAssignmentsSetCommentsComments using ' or RemConstants/LiteralsEmptyNothingNullTrue,FalseControl flowDo...LoopFor...NextFor Each...NextIf...Then...ElseSelect CaseWhile...WendWithConversionsAbsAsc, AscB, AscWChr, ChrB, ChrWCBool,CByteCCur,CDateCDbl,CIntCLng,CSng,CStr DateSerial,DateValueHex,OctFix,IntSgnTimeSerial,TimeValueDates/TimesDate,Time DateAdd,DateDiff ,DatePart DateSerial,DateValueDay,Month,MonthName Weekday,WeekdayName,Year Hour,Minute,Second NowTimeSerial,TimeValueDeclarationsClassConstDim,Private,Public,ReDim Function,SubProperty Get,Property Let,Property Set Error HandlingOn ErrorErrExpressionsEvalExecuteRegExpReplaceTestFormatting StringsFormatCurrencyFormatDateTimeFormatNumberFormatPercentInput/OutputInputBoxLoadPicture

Template

Jul 23, 2017
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks