Có 40+ tài liệu thuộc chủ đề "ứng dụng lập trình"
tailieu.vn Xem trực tuyến Tải xuống
strResults = “None”. ‘Prompt the user to select a choice. strAnswer = InputBox(“Please type Paper, Rock, or Scissors.” &. “Rules:” &. Guess the same thing as the computer to tie.” &. Paper covers rock and wins.” &. Rock break scissors and wins.” &. Scissors cut paper and win.” &. If intGetRandomNumber = 3 Then strResults = “Tie”. If intGetRandomNumber =...
tailieu.vn Xem trực tuyến Tải xuống
space(46) &. space(20) &. space(31) &. space(26) &. space(34) &. space(22) &. space(37) &. space(17) &. space(10) &. If intPlayGame = 6 Then ‘User elected to play the game. strAnswerOne = InputBox(“What was the Science Officer’s name in the “ &. “original Star Trek series. “spock” Then intNumberCorrect = intNumberCorrect + 1 End If. Else ‘User doesn’t want to play....
tailieu.vn Xem trực tuyến Tải xuống
Do…While. The Do...While statement creates a loop that runs as long as a specified condition is true.. VBScript supports two different versions of the Do...While loop. The syntax for the first ver- sion of the Do...While loop is as follows:. In this example, the expression ( intCounter <. 10 ) allows the loop to continue as long as the value...
tailieu.vn Xem trực tuyến Tải xuống
After testing to see whether the script works as expected, retest it to see whether you can break it. Once you’re satisfied with the operation of the script, keep reading. One is by opening the Windows Command Console and typing in the name of an execution host, followed by the path and filename of your scripts at the Windows Command...
tailieu.vn Xem trực tuyến Tải xuống
“\\GuessANumber.lnk”). objNewShortcut.TargetPath = “C:\ GuessANumber.vbs”. What makes working with the Quick Launch toolbar different than working with other Windows special folders is that you must specify the location of the Quick Launch toolbar within the special folder ( AppData ) that contains it.. Figure 6.17 shows how the Quick Launch toolbar appears once the shortcut of your VBScript game has...
tailieu.vn Xem trực tuyến Tải xuống
As I deliberately avoided using procedures in the script from Chapter 6, I had to use other techniques for organizing the script’s programming logic. What I chose to do was put every- thing in the script’s main processing section as follows:. Added statements that generate a random number. Added a Do...Until loop that controls the game’s execution. Embedded an If...
tailieu.vn Xem trực tuyến Tải xuống
Space(15) &. “Rules and “ &. “Instructions” &. Space(32) &. Space(31) &. Try to get to “ &. “21 without going over.” &. Aces count as “ &. The dealer “ &. “must stop at 17 or later.” &. Space(16) &. Space(17) &. Space(18) &. Space(14) &. Space(11) &. Space(12) &. Space(9) &. Space(10) &. Space(13) &. Space(19) &. Space(33)...
tailieu.vn Xem trực tuyến Tải xuống
This is a pretty big script, so you may have to fix a few syntax errors introduced by typos you may have made when keying in the script. In this chapter you learned how to use procedures to streamline the organization of your VBScripts, allowing you to develop larger and more complex scripts, and, of course, games.. In addition, you...
tailieu.vn Xem trực tuyến Tải xuống
‘a line of text to a text file.. strFileName = “C:\Temp\Sample.txt”. Set objFileHandle = objFso.OpenTextFile(strFileName, 8) Else. ‘Write 3 lines of text to the text file. objFileHandle.WriteLine “Once upon a time there was a little boy who”. objFileHandle.WriteLine “lived in a shoe. objFileHandle.WriteLine “too small!”. ‘Close the file when done working with it objFileHandle.Close(). You do this by using the...
tailieu.vn Xem trực tuyến Tải xuống
You can copy one or more files using the CopyFile() method. This method also supports an additional parameter that allows you to specify what to do if the script attempts to copy a file to a folder that already contains a file with the same name. The following example demonstrates how to copy all files with a .txt file extension...
tailieu.vn Xem trực tuyến Tải xuống
The script’s main processing section controls the overall execution of the script. The first loop is controlled by a For statement that is responsible for making sure that the script generates the number of sets of lottery numbers specified by the player. The second loop is controlled by a Do Until and is responsible for making sure that a full...
tailieu.vn Xem trực tuyến Tải xuống
Dim FsoObject ‘Sets up a reference to the FileSystemObject Dim OpenFile ‘Sets up a reference to the script’s .ini file. Dim strKeyName ‘Represents a key in the script’s .ini file Dim strSourceFile ‘Specifies the name of the script’s .ini file Dim strInput ‘Represents a line in the script’s .ini file. MsgBox “The .ini file is missing. ‘for the selection of...
tailieu.vn Xem trực tuyến Tải xuống
With proper testing of all the components of a script, most run-time errors can be discov- ered and fixed during script development. I say “most” because not all run-time errors can be caught—those caused by unforeseen circumstances may be impossible to detect during script development. Perhaps the person running the script incorrectly supplied input in a manner that you could...
tailieu.vn Xem trực tuyến Tải xuống
To use the Clear() method, place it at the end of your error-handling routine, as demonstrated in the previous example. Without this method, the only way that you could test your error-handling routines would be to deliberately introduce an error sit- uation into your code. Err.Raise(500). For example, if you save the previous statement as a script and run it,...
tailieu.vn Xem trực tuyến Tải xuống
‘The Player wants to quit the game If strProcessGuess = “ExitFunction” Then. Exit Function End If. ‘The player typed invalid input If strProcessGuess <>. “SkipRest” Then. “IncorrectAnswer” Then. ‘the interim stage of the word as currently guessed by player strTempStringTwo. ‘Check to see if the player has guessed the word blnGameStatus = CheckIfGameWon(). Exit Do End If. ‘Set the value...
tailieu.vn Xem trực tuyến Tải xuống
‘Initialize variables displayed by the game’s initial pop-up dialog intNoMisses = 0. ‘Get the game a mystery word strGameWord = RetrieveWord(). ‘Let the player start guessing Do Until intNoMisses = 6. ‘Collect the player’s guess. ‘Determine if the player has quit If strChoice. Exit Function End If. ‘The player wants to quit the game If strProcessGuess = “ExitFunction” Then. ‘The...
tailieu.vn Xem trực tuyến Tải xuống
Figures 10.1 through 10.6 demonstrate the overall flow of the game from beginning to end.. Figure 10.1. Figure 10.2. Figure 10.3. Figure 10.4. The flow of the game runs exactly. By the time you’ve finished writing the new Hangman setup script and modifying the orig- inal Hangman game, you’ll have a basic understanding of the Windows Registry and what it...
tailieu.vn Xem trực tuyến Tải xuống
This script will create and store a Registry key called Hangman in the HKEY_CURRENT_USER root key (referred to in the script as HKCU. Within this key, a value called ListLocation will be created and assigned a string iden- tifying the location where you plan to store your Hangman word files. Set up the controlling logic in the Main Processing Section,...
tailieu.vn Xem trực tuyến Tải xuống
End If. ‘Display the splash screen and ask the user if he or she wants to play strSplashimage = Space(100) &. Space(68) &. Space(18) &. Space(100) &. Space(50) &. Space(15) &. Space(99) &. Space(1) &. Space(17) &. Space(120) &. space(113) &. “Would you like to play a game?” &. ‘Initialize variables displayed in the game’s initial pop-up dialog intNoMisses =...
tailieu.vn Xem trực tuyến Tải xuống
Microsoft WSH and VBScript Programming for the Absolute Beginner, Second Edition. Create new collection of word files to increase the number of categories avail- able to the player.. Add an error-handling routine to the HangmanSetup.vbs script and use it to report any problems that may occur when the script attempts to perform the RegWrite() method.. Modify HangmanSetup.vbs to display a...