tailieunhanh - Microsoft WSH and VBScript Programming for the Absolute Beginner Part 21
Microsoft WSH and VBScript Programming for the Absolute Beginner by Jerry Lee Ford Part 21. If you are new to programming with Microsoft WSH and VBScript and are looking for a solid introduction, this is the book for you. Developed by computer science professors, books in the for the absolute beginner series teach the principles of programming through simple game creation. You will acquire the skills that you need for more practical WSH and VBScript programming applications and will learn how these skills can be put to use in real-world scenarios. Best of all, by the time you finish this book,. | Microsoft WSH and VBScript Programming for the Absolute Beginner Second Edition The statement creates a loop that runs as long as a specified condition is true. VBScript supports two different versions of the loop. The syntax for the first version of the loop is as follows Do While condition statements Loop Condition is expressed in the form of an expression like this intCounter 0 Do While intCounter 10 intCounter intCounter 2 Loop In this example the expression intCounter 10 allows the loop to continue as long as the value of intCounter is less than 10. The value of intCounter is initially set to 0 but is increased by 2 every time the loop executes. As a result the loop iterates five times. As the While keyword has been placed at the beginning of the loop the loop will not execute if the value of counter is already 10 or greater. The syntax for the second format of the statement is as follows Do statements Loop While condition As you can see the While keyword had been moved from the beginning to the end of the loop. Therefore the loop will always execute at least once even if the condition is initially false. Let s look at another example of the loop in action. In this example the loop is set up to collect names and phone numbers for an address book. The loop uses the VBScript InputBox function to collect the names and phone numbers. The names and addresses are added to a variable string and formatted such that when displayed each entry is listed on a separate line. The user may enter as many names and numbers as he or she wishes. When done adding new address book entries all he or she must do is type Quit as the final entry. Dim intCounter strAddressBook strAddressEntry intCounter 0 Chapter 6 Processing Collections of Data Do While strAddressEntry Quit intCounter intCounter 1 strAddressEntry InputBoxCPlease type a name a space and then the person s phone number Personal Address Book If strAddressEntry
đang nạp các trang xem trước