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

Microsoft WSH and VBScript Programming for the Absolute Beginner by Jerry Lee Ford Part 9. 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 first statement is a comment and can be ignored. The second statement uses the VBScript InputBox function to display a pop-up dialog into which the user can type either rock paper or scissors. The value typed by the user is then assigned to a variable called Answer. Setting Up the Script s Random Selection Now that the player has selected his or her choice it s the script s turn to make a random selection on behalf of the computer. This can be done in two statements as shown by the following statements Time for the computer to randomly pick a choice Randomize GetRandomNumber Int 3 Rnd 1 The first line is a comment and can be ignored. The second line executes the Randomize statement which ensures that the computer generates a random number. If you leave this line out and run the script several times you ll notice that after making an initial random choice the script always makes the exact same choice time and time again. The Randomize statement prevents this behavior by ensuring that a random number is generated each time the script executes. The next statement generates a random number between 1 and 3. I ll break down the activity that occurs in this statement. First the Rnd function generates a random number between 0 and 1. Next the Int function which returns the integer portion of a number executes multiplying 3 times the randomly generated number and then adding 1 to it. The final result is a randomly generated number with a value between 1 and 3. Assigning a Choice to the Script s Selection Next you ll need to assign a choice to each of the three possible numeric values randomly generated by the script Assign a value to the randomly selected number If GetRandomNumber 3 then Cardimage rock If GetRandomNumber 2 then Cardimage scissors If GetRandomNumber 1 then Cardimage paper If the number 1 is generated then a value of rock is assigned as the computer s selection. If the number

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.