velp10.htm
来自「简单的说明如何使用VB,非常适合初学使用者,而且是用图表来解说的」· HTM 代码 · 共 1,218 行 · 第 1/2 页
HTM
1,218 行
Check for Cancel84: ' Turn off instruction label85: lblInstruct.Visible = False86: Exit Sub ' User pressed Cancel87: End If88: ' Convert user's letter to uppercase89: GuessLet = UCase(GuessLet)90: If (GuessLet > Letter) Then91: MsgBox "Your letter is too high...", , "Wrong"92: Else93: If (GuessLet < Letter) Then94: MsgBox "Your letter is too low...", , "Wrong"95: End If96: End If97: Loop Until (GuessLet = Letter)98:99: ' Here is user guessed number100: Beep101: MsgBox "You guessed " & GuessLet & "! Correct!!!", , "Lucky"102:103: ' Turn off instruction label104: lblInstruct.Visible = False105: End Sub</FONT></PRE><BR><A NAME="E69E142"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Descriptions</B></FONT></CENTER></H4><BR><P>1: The code for the opening event procedure that executes right before the user sees the form.<BR><P>2: A remark explains the procedure.<BR><P>3: The remark continues.<BR><P>4: The remark continues.<BR><P>5: Set the guess to letters.<BR><P>6: A remark explains the code.<BR><P>7: Right justify the Help menu option.<BR><P>8: A remark explains the code.<BR><P>9: Use the internal clock to seed the random number generator.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>9: Be sure to seed the random number generator so that truly random values appear.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>10: Terminate the procedure.<BR><P>11: A blank line separates the procedures.<BR><P>12: The code for the File Exit menu command.<BR><P>13: Terminate the program's execution.<BR><P>14: Terminate the procedure.<BR><P>15: A blank line separates the procedure.<BR><P>16: The code for the File New Game menu command.<BR><P>17: A remark explains the procedure.<BR><P>18: The remark continues.<BR><P>19: A blank line helps separate parts of the program.<BR><P>20: A remark that explains the procedure.<BR><P>21: Turn off the display of the Press File New Game label if it's on.<BR><P>22: Hide the label.<BR><P>23: Terminate the If.<BR><P>24: A blank line helps separate parts of the program.<BR><P>25: See whether the user wants to guess a letter.<BR><P>26: Execute the subroutine procedure that enables the user to guess a letter.<BR><P>27: If the user wants to guess a number...<BR><P>28: Execute the subroutine procedure that enables the user to guess a number.<BR><P>29: Terminate the If.<BR><P>30: A remark explains the code.<BR><P>31: Now that the user has finished the game, turn the Select File New Game label.<BR><P>32: Terminate the procedure.<BR><P>33: A blank line helps separate parts of the program.<BR><P>34: The code for the Option use Alphabetic Letters menu command.<BR><P>35: A remark helps explain the procedure.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>35: Check or uncheck the menu command when clicked.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>36: Turn the menu command's check mark either on or off.<BR><P>37: Terminate the procedure.<BR><P>38: A blank line helps separate the procedures.<BR><P>39: The subroutine procedure called when the user wants to guess a number.<BR><P>40: A remark explains the procedure.<BR><P>41: Define a variable to hold the InputBox() function's return value.<BR><P>42: Define variables to hold the user's guess and the random number generated for the guessing game.<BR><P>43: A blank line helps separate parts of the procedure.<BR><P>44: A remark explains the code.<BR><P>45: Change the label that appears at the bottom of the screen during the user's guessing.<BR><P>46: Displays the guessing label.<BR><P>47: A remark explains the code.<BR><P>48: Generate a random number from 1 to 100.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>48: Unless you convert the value fall within a different range, Visual Basic generates a number from 0 to 1.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>49: A blank line helps separate parts of the code.<BR><P>50: Begin the guessing loop.<BR><P>51: Get the user's guess.<BR><P>52: Check to see whether the user pressed the Cancel command button at the display of the input box.<BR><P>53: A remark explains the code.<BR><P>54: Turn off the guessing label.<BR><P>55: Terminate the guessing subroutine early.<BR><P>56: Terminate the If.<BR><P>57: Convert the user's Variant answer to an Integer.<BR><P>58: Check whether the user's guess was too high.<BR><P>59: If the user's guess was too high, tells the user.<BR><P>60: The user's guess was not too high.<BR><P>61: Check whether the user's guess was too low.<BR><P>62: If the user's guess was too low, tells the user.<BR><P>63: Terminate the If.<BR><P>64: Terminate the If.<BR><P>65: Keep asking the user for a guess until the user guesses the correct answer.<BR><P>66: Audibly tells the user that the guess was correct.<BR><P>67: Show the user that the guess was correct.<BR><P>68: A remark helps explain the code.<BR><P>69: Hide the guessing instructional label.<BR><P>70: Terminate the procedure.<BR><P>71: A blank line helps separate procedures.<BR><P>72: The subroutine procedure called when the user wants to guess a letter.<BR><P>73: A remark explains the procedure.<BR><P>74: Define a variable to hold the user's guess and the random letter.<BR><P>75: A blank line helps separate parts of the procedure.<BR><P>76: A remark explains the code.<BR><P>77: Change the label that appears at the bottom of the screen during the user's guessing.<BR><P>78: Display the guessing label.<BR><P>79: A remark explains the code.<BR><P>80: Generate a random letter from A to Z.<BR><P>81: Begin the guessing loop.<BR><P>82: Get the user's guess.<BR><P>83: Check to see whether the user pressed the Cancel command button at the display of the input box.<BR><P>84: A remark explains the code.<BR><P>85: Turn off the guessing label.<BR><P>86: Terminate the guessing subroutine early.<BR><P>87: Terminate the If.<BR><P>88: A remark explains the code.<BR><P>89: Convert the user's guess to uppercase if the letter is not already uppercase.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>89: The UCase$() function keeps the user's guessing range within the uppercase letters.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>90: Check whether the user's guess was too high.<BR><P>91: If the user's guess was too high, tells the user.<BR><P>92: The user's guess was not too high.<BR><P>93: Check whether the user's guess was too low.<BR><P>94: If the user's guess was too low, tells the user.<BR><P>95: Terminate the If.<BR><P>96: Terminate the If.<BR><P>97: Keep asking the user for a guess until the user guesses the correct answer.<BR><P>98: A blank line helps separate parts of the code.<BR><P>99: A remark helps explain the code.<BR><P>100: Audibly tells the user that the guess was correct.<BR><P>101: Show the user that the guess was correct.<BR><P>102: A blank line helps separate parts of the code.<BR><P>103: A remark helps explain the code.<BR><P>104: Hide the guessing instructional label.<BR><P>105: Terminate the procedure.<BR><BR><A NAME="E69E143"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Close the Application</B></FONT></CENTER></H4><BR><P>You can now exit the application and exit Visual Basic. The next lesson teaches you how to send text to the printer and really have fun by drawing graphics on the user's form.<A NAME="I2"></A><P ALIGN=LEFT><A HREF="vel20.htm" TARGET="_self"><IMG SRC="purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A><A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A><A HREF="index.htm" TARGET="_self"><IMG SRC="purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A><A HREF="vel21.htm" TARGET="_self"><IMG SRC="purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?