TAILIEUCHUNG - Microsoft WSH and VBScript Programming for the Absolute Beginner Part 16

Microsoft WSH and VBScript Programming for the Absolute Beginner by Jerry Lee Ford Part 16. 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 syntax of the Ubound function is Ubound ArrayName Dimension ArrayName is the name of the array whose upper bound is to be returned. Dimension is used to specify the array dimension whose upper bound is to be returned. For example you could retrieve the upper bound of a single dimension array called astrltsMyparty as shown here intSize Ubound astrltsMyParty In this case the upper bound of the array is assigned to a variable named intSize. Let s look at a quick example of the Ubound function in action Dim intCounter Define a variable to be used when processing array contents Dim strMessage Define a variable to be used to store display output Dim astrGameArray 2 Define an array that can hold 3 index elements astrGameArray O Joe Blow The default username astrGameArray l Nevada A place worth visiting astrGameArray 2 Soda Can An interesting object intSize UBound astrgameArray For intCounter 0 to intSize strMessage strMessage astrGameArray intCounter vbCrLf Next MsgBox strMessage Run this example and you ll see that the script displays all three elements in the array in a pop-up dialog. Resizing Arrays Sometimes it s impossible to know how many elements an array will need to store when developing your scripts. For example you might develop a script that uses the InputBox function to prompt the user to specify the data to be stored in the array. You might expect the user to specify only a few pieces of data but the user may have an entirely different idea. To handle this type of situation you need a way of resizing the array to allow it to store the additional data. Chapter 4 Constants Variables and Arrays One way of dealing with this situation is to define the array without specifying its size like this Dim astrGameArray This lets you define the array s size later in the script. For example you might want to define the array and later ask the user how many pieces of data he or she intends

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.