* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '
'' Waizen Game General Project Introduction '
'' '
'This game we mainly passed the use of the class to see how the OOP in VB is used. The main documents and their main functions are as follows: '
'' '
'Winmine. CLS: This is a class module, which implements the main functionality in the game'
'' '
'Winmine. FRM: This is the game display winner window, she is a main interface interface with players interacting and entertaining, and it also shows the use of Winmine. CLS classes in the game mode method
'' '
'Cords. CLS: This is another class module, which is mainly used to mark the X, Y coordinate position of mines that are falsely marked.
'' '
'Custdlg. FRM: This is a custom game level form, when you click on the game display Source Fact, the dialog is displayed in mode status, so you must make a choice, otherwise you can't return it. Game Real Main Window for Game '
'' '
'INSTRUCT. Frm: This is a form file that when the F1 button is pressed, the window is displayed to display the game rules and the gameplay.
'Guidance,'
'' '
'About. FrM is also a form file used to display some related information, etc.' ''
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Two variables defined in the Coords.cls class module
'Define an object to save the X, Y axis coordinate PUBLIC MINTX AS INTEGER
Public Minty As Integer
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Create a class in Winmine. CLS class module to facilitate control of mine-mine games:
Option expedition
'Define the left button of the mouse, the defined constant VBKEYLBUTTON in VB, value is 1
Private const left_button as byte = 1
'Marking a checkered sign
Private const none as byte = 0
'Marker is a checkered square
Private const mine as byte = 243
'Marker is a checkered
Private const been as byte = 244
'Marking a checker is marked as a line of lane
Private const flagged as byte = 2
'Marker is marked as a question mark, that is, a checkered in question, cannot be determined
Private const Question as byte = 1
'Define the number of rows and columns of the largest and smallest mine map in the mine game and the number of mines
PRIVATE CONST Min_Mines as Byte = 10
'Minimum mine number
Private const min_rows as integer = 8
Private const min_cols as in integer = 8
'Minimum number of rows of rows
Private const Max_mines as byte = 99
'Maximum mna
Private const max_rows as integer = 24
Private const Max_cols as integer = 36
'Maximum number of rows of maps
'Set the width of each checker to 16 pixels
Private const mintbuttonwidth as byte = 16
'Set the width of each checker to 16 pixels
Private const mintButtonHeight as byte = 16
'Record the level of players in the current game
Private mbytnummines as byte
'Record the number of mines that are correctly marked by the player in the current game
Private MBytcorRecthits as Byte
'Record the number of mines that are marked by the player sign in the current game, including the wrong mark
Private MByttotalhits as Byte
'Record in the current game, the number of rows and columns set
Private mintrows as in
Private Mintcols as in
'Record the number of rows and columns of the number of clicks on the game by players in the game
Private Mintrow AS Integer
Private Mintcol as in
'Do you start a sign of a new game
Public MBLNNEWGAME As Boolean
'In the ongoing game, the mouse click the sign of the event
Private mblnhittestbegun as boolean
'Define the main form displayed by the game
Private mfrmdisplay as Form
'Define a dynamic two-dimensional array that saves the location of the square, and there is no mine around the location, how many mines
Private mbytminestatus () as byte 'defines a dynamic two-dimensional array to save the marked checkered position, whether this tag is marked correctly
Private mbytmarked () AS BYTE
'Define a dynamic two-dimensional array to save the coordinate position of the total number of mines in the distributed mine region.
Private mbytminelocations () as Byte
'Define a collection to store the X, Y axis coordinate position of the Clscoords class object, indicating the location of the mailed error in the game.
Private MCOLWRONGLOCATIONS AS New Collection
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'' '
'Role: Judgment that mouse button is clicked, and the location of the game player is judged by clicking on the form.
The mouse in the re-main form display area is called in the event.
'Enter parameters of the function: INTBUTTON: indicates which mouse button is clicked (left button or right button and middle key)
'Inx: Record the mouse button Clicked position in the coordinate of the X-axis'
'INY: Record the coordinates of the mouse button clicked on the Y-axis
'Return value: no
'
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Public Sub Beginhittert (INTBUTTON AS INTEGER, INTX As Single, INTY AS SINGLE)
'If the mblnnewgame value is true, it means a sign started with a new game, so the current game is over, and start a new game, the MBLnneWGame variable is defined in front.
IF mblnnewgame dam
Newgame 'call this function to start a new game
END IF
'If the game is going on, then the value of MBLnHitTestBegun is true, indicating the beginning of the mouse click event.
MblnhittestBegun = TRUE
'Determination of the position of the mouse click, in the previous definition, defined as the width and height of each checker, with the obtained mouse click position, with the aspect of the square, and get a mouse click. Which checkered, the first few columns in the square
INTX = Int (INTX / MINTBUTTONWIDTH)
Intery = int (intY / mintButtonHeight)
'If the click position exceeds the window range of the set game, then exit this process, that is, do not do any action.
IF INTX> = mintcols or inty> = mintrows or intx <0 or inty <0 THEN
'If the X-axis of the mouse click is greater than the number of rows of the game effective window,
'Or the y-axis of the mouse click is greater than the number of columns of the game effective window.
'Or the x-axis of the mouse click smaller than the minimum position of the game valid window.
'Or the y-axis of the mouse click is smaller than the minimum position of the game effective window.
'The location of the mouse click has exceeded the effective window of the game.
'So I quit this process, that is, what actions do not perform exit sub
END IF
'INTX * MINTBUTTONWIDTH The X-axis of the position coordinate from the new to the mouse in the window, and assigns the value to the Mintcol variable
'Inty * MintButtonHeight from the new to the position of the position coordinate in the window, and assign the value to the Mintcol variable
Mintcol = Intx * MintButtonWidth
MINTROW = INTY * MINTBUTTONHEIGHT
'Call the mbytminestatus () function, determine the state of the mouse click x, y, if this checker has been opened,
'So that you have to exit the process, you don't happen.
If MBYTMINESTATUS (INTY, INTX)> = Been Then EXIT SUB
'Define the variable blnleftdown in this process, so that the left mouse button is pressed.
DIM BLNLNLEFTDOWN AS BOOLEAN
'Use the resulting mouse click button with the defined constant, if it is greater than 0, then assign the blnlexDown to true,
'Description Press is the left mouse button, of course, you can also use the numerical judge to change the following statement to
'blnleftdown = (intButton - Left_Button> 0
'Or back
'blnleftdown = (intButton and left_button> 0
The two sentences of 'if blnleftdown kil
'If intButton = 1 THEN
BLNLEFTDOWN = (intButton and LEFT_BUTTON> 0
'If the left mouse button is clicked
IF blnleftdown then
'Call the mbytmarked (intx) function to determine if the mouse is marked as there
'If the return value is greater than or equal to 2 (ie flagged), the description has been marked, do not do any action, exit this process
IF mbytmarked (inty, intx)> = flagged killed the exit sub
'Call the mbytmarked (intx) function to determine if the mouse is marked as question mark, that is, it cannot be determined
'If the return value is equal to 1 (ie Question), the description has been marked as a question mark.
'So the picture is pressed in the original location
IF mbytmarked (intery, intx) = Question Then
mfrmdisplay.imgpressed.visible = false
mfrmdisplay.imgqspressed.visible = false
mfrmdisplay.imgqspressed.Left = Mintcol
mfrmdisplay.imgqspressed.top = MINTROW
mfrmdisplay.imgqspressed.visible = TRUE
Else
'Call the mbytmarked (intx) function to determine if the mouse is marked as question mark, that is, it cannot be determined
'If the return value is not equal to 1 (ie questions), the description is not marked.
'So the picture is pressed in the original location
mfrmdisplay.imgqspressed.visible = false
mfrmdisplay.imgpressed.visible = false
mfrmdisplay.imgpressed.Left = Mintcol
mfrmdisplay.imgpressed.top = mintrow
Mfrmdisplay.imgpressed.visible = TRUE
END IF
Else
'If you press, right-click DIM MSG AS String
DIM CRLF AS STRING
CRLF = CHR $ (13) & chr $ (10)
Select Case MBytmarked (INTY, INTX)
'Call mbytmarked (intx) function to determine if the mouse is tagged
Case None:
'If the return value is greater than or equal to 0 (ie none), then this is an empty sign bit
If mbyttotalhits = mbytnummines dam
'If all the mine in the game is equal to the number of markings marked
'Then the dialog prompts the player to mark more and thunder markers.
Msg = "Cannot mark more and thunder marks" & CRLF
Msg = msg & "There is one or more positions being erroneous markers are thunder" & CRLF
Msg = msg & "Cannot use the right button to mark more thunder."
MsgBox MSG, Vbcritical, "Minesweeper: Error"
EXIT SUB 'exits the process
END IF
'If you can also mark the thunder, then the corresponding lane flag is displayed in the position of the mouse.
MFRMDisplay.PaintPicture MfrmDisplay.imgflag, Mintcol, Mintrow
After ', add the number of mines that mark the number of mines.
MByttotalhits = MBYTTOTALHITS 1
'mbytnummines - mbyttotalhits indicates that the total mine number is subtracted.
'For the number of mines, you get unused markers
MFRMDisPlay.lblmineSleft = "Remaining mines:" & mbytnummines - MByttotalhits
'If the status of the current position of the mouse is thunder, then mark the correct number of thunder 1. And set this location to have labeled
IF mbytminestatus (inty, intx) = mine then
MBYTCORRECTHITS = MBYTCORRECTHITS 1
MBytmarked (intX) = flagged
Else
'If the status of the current location of the mouse is not kept, that is, the location is missed, then an example of a CLSCoRDS class used to store all the missing missing mines
DIM Objcoords as new clscoords
'Store the X, Y coordinate position of the Mali-marked mine in the instance of the new CLSCoRDS class
Objcoords.mintx = INTX
Objcoords.minty = intY
'Examples of adding a CLSCoRDS class in Collecting McOLWRONGLOCATIONS
MCOLWRONGLOCATIONS.Add Objcoords
'And store the index of the error tag compilation in the MBytMarked array
MBytmarked (intx) = mbyttotalhits - mbytcorrecthits 2
END IF
'If all mines are properly marked out, then dialogue Tips "Congratulations! You will win!"
IF mbytcorrecthits = mbytnummines dam
Msg = "Congratulations!" & CRLF
Msg = msg & "You have won!" & CRLF
Msgbox MSG, Vbinformation, "Minesweight"
'Ready to start a new game
Mblnnewgame = true
END IF
Case Question: 'If the return value is equal to 1 (ie Question), then explanation Here is a flag as a question mark flag, so set the status of this position to None, which is set to an empty flag.
MBYTMARKED (INTY, INTX) = NONE
'Show normal button graphics in this position
Mfrmdisplay.paintPicture MFRMDisplay.Imgbutton, Mintcol, Mintrow
Case Else:
'If the return value is another value, that is, for a state marked as the mine, then change it to the question mark sign.
Mfrmdisplay.paintPicture Mfrmdisplay.imgquestion, Mintcol, Mintrow
'And reduce the total number of mines with markers
mbyttotalhits = mbyttotalhits - 1
'Display the remaining mark
MFRMDisPlay.lblmineSleft = "Remaining mines:" & mbytnummines - MByttotalhits
'If the position of the mouse click is a mine, then
IF mbytminestatus (inty, intx) = mine then
'Because of the correct mine sign, change it to the question mark, the correct logo minus 1
MBYTCORRECTHITS = MBYTCORRECTHITS - 1
Else.
'If the position status of the mouse is not a mine, that is, the start mark is wrong, then modified, for correct, so remove this mark from the error tag table.
McOLWRONGLOCATIONS.REMOVE MBYTMARKED (INTY, INTX) - 2
DIM INTXWM AS INTEGER 'Error Markup X - axis coordinate position
DIM INTYWM AS INTEGER 'Error Marking Computer Y-axis coordinate position
DIM I as integer '
'Delete the index of the error tag compilation in the mbytmarked array
For i = mbytmarked (intx) - 2 to MCOLWRONGLOCATIONS.COUNT
INTXWM = MCOLWRONGLOCATIONS (i) .MINTX
InteryWM = MCOLWRONGLOCATIONS (i) .MINTY
MBytmarked (intyWM, INTXWM) = mbytmarked (intYWM, INTXWM) - 1
NEXT
END IF
'Change the position of the mouse click to ask questions
MBYTMARKED (INTY, INTX) = Question
End SELECT
END IF
End Sub
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ''
'Description: When the mouse is pressed, the mouse cursor is passed by the mouse cursor, thereby deciding what action is generated, this process is called when the mouse bomb is generated in the game display main window.
'
'Enter parameters of the function: INTBUTTON: indicates which mouse button is clicked (left button or right button and middle key)
'Inx: Record the mouse button Clicked position in the coordinate of the X-axis'
'INY: Record the coordinates of the mouse button clicked on the Y-axis
'
'Return value: no
'$ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Public Sub Endhittest (INTBUTTON AS INTEGER, INTX As Single, INTY AS Single)
'If the current ongoing mouse click the logo of the event mblnhittestbegun is true
IF mblnhittestbegun the
'So from the new settings, this logo is fake
MblnhittestBegun = false
Else
'If the current ongoing mouse click the logo mblnhittestbegun for the false, then the position of the mouse can be broken is not the legal position of the game owner display window, so do not do any action, exit the process
EXIT SUB
END IF
DIM BLNLNLEFTDOWN AS BOOLEAN
BLNLEFTDOWN = (intButton and LEFT_BUTTON> 0
'If the left mouse button is pressed
IF blnleftdown then
'Determination of the position of the mouse click, in the previous definition, defined as the width and height of each checker, with the obtained mouse click position, with the aspect of the square, and get a mouse click. Which checkered, the first few columns in the square
INTX = Int (INTX / MINTBUTTONWIDTH)
Intery = int (intY / mintButtonHeight)
'If the click position exceeds the window range of the set game, then exit this process, that is, do not do any action.
IF INTX> = mintcols or inty> = mintrows or intx <0 or inty <0 THEN
'If the X-axis of the mouse click is greater than the number of rows of the game effective window,
'Or the y-axis of the mouse click is greater than the number of columns of the game effective window.
'Or the x-axis of the mouse click smaller than the minimum position of the game valid window.
'Or the y-axis of the mouse click is smaller than the minimum position of the game effective window.
'The location of the mouse click has exceeded the effective window of the game.
'So I quit this process, that is, what is the action is not
EXIT SUB
END IF
'If the slate of the mouse is safe, the slate of the release of the release is marked, then what actions do not do, exit the process
IF mbytmarked (inty, intx)> = flagged killed the exit sub
'If the quarter of the mouse stencil is released, the coordinates of the last effective position of the mouse cursor is calculated.
INTX = Mintcol / MintButtonWidth
Intery = mintrow / mintButtonheight
'If the coordinate position is marked as a question mark, then the question mark icon is not displayed.
'Otherwise, do not show the icon pressed by the mouse.
IF mbytmarked (intery, intx) = Question Then
mfrmdisplay.imgqspressed.visible = false
Else
mfrmdisplay.imgpressed.visible = false
END IF
'Judging the position of the mouse bomb position, checkered state
Select Case MBytminestatus (INTY, INTX)
Case is> = been:
'If the mouse square in the current location is opened, then everything is not done, exiting the process
EXIT SUB
Case None:
'If the status of the current square is empty, turn on all the empty checkered around it.
OpenBLANKS INTX, INTY
Case Mine:
'If you contain mines in the current square, then you step on the mine's X coordinate of the Dim Intxm AS INTEGER' mine distribution area.
Dim Inteder's y coordinate in the mine distribution area
DIM VNTCOORD AS VARIANT 'Cycle Count
DIM I as integer 'cycle count value
'Show all checkers that contain mines
For i = 0 to mbytnummines - 1
'Take all the coordinates of the squares containing mines in the mbytminelocations array
Interm = MBytminelocations (i, 0)
INTXM = MBYTMINELOCATIONS (i, 1)
'If the square of this coordinate position has been marked, then the flag icon is displayed.
IF mbytmarked (intXM, INTXM) Mfrmdisplay.paintPicture MFRMDisplay.Imgmine, Intxm * MintButtonWidth, INTYM * MINTBUTTONHEIGHT END IF NEXT 'Display the mine icon in the current square Mfrmdisplay.paintPicture MFRMDisplay.imgblown, Mintcol, Mintrow 'Show all icons of all missing mines (with differential numbers) For Each Vntcoord in McOLWRONGLOCATIONS 'Take marked in McOLWRONGLOCATION icon position Interm = Vntcoord.minty INTXM = VNTCOORD.MINTX 'Show all the icons of the missing mines MFRMDisplay.paintPicture MFRMDISPLAY.IMGWRONGMINE, INTXM * MINTBUTTONWIDTH, INTYM * MINTBUTTONHEIGHT NEXT 'Ready to start a new game Mblnnewgame = true DIM CRLF AS STRING CRLF = CHR $ (13) & chr $ (10) 'Dialog prompt "You lose!" Msgbox "You lost!", Vbexclamation, "mine" Case Else: 'If there is one or more squares around this checker, it contains the geographic numbers contained around it. MFRMDisplay.PaintPicture Mfrmdisplay.Imgpressed, Mintcol, Mintrow Mfrmdisplay.currentx = Mintcol mfrmdisplay.currenty = mintrow MfrmDisplay.ForeColor = QBColor (MBytminestatus (INTY, INTX)) MFRMDisplay.print MBytminestatus (INTY, INTX) 'And mark this location has been opened MBYTMINESTATUS (INTY, INTX) = MBytminestatus (INTY, INTX) BEEN End SELECT END IF End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' 'Description: When the display size of the old object is given a new attribute value, the process is called This process is called when the main display form is loaded. ' 'Enter parameters: frMDisplay: Older main display form object' '' ' 'Output parameters: no' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public property set frMdisplay (frMDisplay as form) 'Property is expressed as a class of properties, the property name is frMDisplay Set mfrmdisplay = frMDisplay Mfrmdisplay.fontbold = TRUE 'Set the size and mine set in the game to determine the size of the main form ResizeDisplay End Property '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' ' 'Description: Display the number of mines, columns and minens of mines, columns and minensis set in the current game, in the text box of the custom dialog ' 'Enter parameters: frMDisplay: Older main display form object' '' ' 'Output parameters: no' '' ' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public Sub getMinefieldDimensions (frMDialog as form) 'Get the number of rows, columns and minensis of mines, columns and mines frMDialog.txtrols = mintrows frMDialog.txtColumns = MintCols frMDialog.txtMines = MBytnummines 'In the text box that highlights it in the custom dialog FRMDIALOG.TXTROWS.SELLENGTH = LEN (frMDialog.txtrows) frMDialog.txtColumns.Sellength = len (frMDialog.txtColumns) frMDialog.txtMines.sellength = len (frmdialog.txtmines) End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' ' 'Description: According to the size of the mine game set in the current game, the dynamic allocation array size is distributed, and the area of the mine distribution is randomly distributed. 'Enter parameters: no' 'Output parameters: no ' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Private subinitializeminefield () 'Set the size of the two-dimensional dynamic arrays by pressing the ranks and mine Redim MBytminestatus (Mintrows - 1, Mintcols - 1) Redim Mbytmarked (Mintrows - 1, Mintcols - 1) Redim Mbytminelocations (MBYTNUMMINES - 1, 1) 'Generate random mine positions in the mine distribution area, and store it in the MBytminelocations array 'And fill the mBytMinestatus array with mines containing mines with mines and their surroundings. Randomize DIM I as integer ' DIM R AS INTEGER 'Cycling DIM C AS Integer 'Cycling For i = 0 to mbytnummines - 1 DIM INTX AS INTEGER DIM INTY AS INTEGER INTX = INT (RND * MINTCOLS) INTY = INT (RND * MINTROWS) 'If the location of the location is a thunder, then from the new allocation While mbytminestatus (intery, intx) = mine INTX = INT (RND * MINTCOLS) INTY = INT (RND * MINTROWS) Wend 'Marked the status of the location as a mine MBYTMINESTATUS (INTY, INTX) = MINE 'Put this location in a two-dimensional array MBYTMINELOCATIONS (I, 0) = INTY MBYTMINELOCATIONS (I, 1) = INTX 'Find the surroundings around the current location, and judge that when there is no mine distribution area, the state of these 8 locations, as long as every mine distribution is distributed, add them to 1, which is to mark it as unreasonable. For r = -1 to 1 For c = -1 to 1 Dim blndx as boolean Dim blndy as boolean 'Looking around 8 positions around it, see if there is a valid mine distribution area BLndy = INTY R> = 0 and INTY R 'If there is no effective mine distribution area IF blndy and blndx Then 'Judging whether their status has mine distribution IF MBYTMINESTATUS (INTY R, INTX C) <> Mine Then 'If there is no mine distribution, then add it to 1 (ie, set to no thunder), and store it in MBytMinestatus MBYTMINESTATUS (INTY R, INTX C) = MBYTMINESTATUS (INTY R, INTX C) 1 END IF END IF NEXT NEXT NEXT End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' ' 'Description: Start a new game ' 'Enter parameters: no' ' 'Output parameters: no' '' ' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public Sub newGame () 'Clear the display in the backward list mfrmdisplay.cls 'The variables and signs from the new setting game MBYTCORRECTHITS = 0 mbyttotalhits = 0 MINTROW = -1 Mintcol = -1 Mblnnewgame = false MblnhittestBegun = false DIM I as integer ' 'Clearing Error Mark mines McOLWRONGLOCATIONS collection For i = 1 to MCOLWRONGLOCATIONS.COUNT McOLWRONGLOCATIONS.REMOVE 1 NEXT 'From the newly calculated new mine distribution area InitializationMinefield 'From the new settings of the main list Mfrmdisplay.lblminesled = "Remaining mines:" & mbytnummines End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' 'Description: If this is clicked, and where there is no mine, then this process will open all the square around it until you encounter a square containing the landmine, here is used here, interested It can be studied that first starts from the checkered position from the click, until it encounters a square, which is not empty, in this case, the previous scanner position is center, clockwise look around it Whether or not the square contains mine, thus taking out the edge of the square, and stores the X-week coordinate of the position of the edge mine ' 'Enter the parameters of the function: Inx: Record the mouse button Clicked position in the X-axis coordinate' 'INY: Record the coordinates of the mouse button clicked on the Y-axis '' ' 'Return value: no '' ' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Private sub openblanks (byval intx as single, byval interaising) 'Define four Boolean variables to save the moving direction of the lookup action Dim blngoup as boolean Dim blngoright as boolean DIM BLNGODOWN AS BOOLEAN Dim blngoleft as boolean 'the border starts 'X, Y axis coordinate of X, Y axis coordinate for saving the movement of the lookup action DIM INTXSTART AS INTEGER DIM INTYSTART AS INTEGER 'Collecting the location index in the queue DIM INTPOS AS INTEGER 'Circulating count value Dim element as variant 'Circulating count value DIM Y AS Integer DIM X as integer DIM I as integer 'A dynamic integer array collection. Where each element stores the starting and termination of the French X-axis coordinate position. Through this value, you can get the edge of the location containing the mine. DIM colx () AS New Collection 'Set the same size of this array and the number of rows of mine distribution regions Redim Colx (Mintrows - 1) 'Search to the left until you find an empty location that does not contain mines While mbytminestatus (intery, intx) = none INTX = INTX - 1 IF INTX <0 THEN INTX = 0 INTXSTART = INTX INTYSTART = INTY Goto LFT END IF Wend 'First Direction to Go Is Up 'First is search up BLNGOUP = TRUE 'Store this first Non-Empty Mine location as the starting point. 'Save the empty position of the search does not contain mines as a new start position to make a new search INTXSTART = INTX INTYSTART = INTY 'Hook out the boundary until you return to the beginning DO IF mbytminestatus (intery, intx) = none then IF bl NGOUP THEN INTX = INTX - 1 INTY = INTY 1 Colx (intery) .remove (colx (intery) .count) BLNGOUP = FALSE BLNGOLEFT = TRUE Elseif Blingoright Then INTX = INTX - 1 INTY = INTY - 1 BLNGORIGHT = FALSE BLNGOUP = TRUE Elseif Blngodown Then INTX = INTX 1 INTY = INTY - 1 Colx (intery) .remove (colx (intery) .count) BLNGODOWN = FALSE BLNGORIGHT = TRUE Elseif blngoleft then INTX = INTX 1 INTY = INTY 1 BLNGOLEFT = FALSE BLNGODOWN = TRUE END IF IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO Else IF bl NGOUP THEN Colx (intery) .add intx IF MBytminestatus (INTY, INTX 1) = None Then IF intery = 0 THEN BLNGOUP = FALSE Up: INTX = INTX 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO While mbytminestatus (intery, intx) = none IF INTX = MintCols - 1 THEN GOTO RIGHT INTX = INTX 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO Wend BLNGODOWN = TRUE Else INTY = INTY - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO END IF Else BLNGOUP = FALSE BLNGORIGHT = TRUE INTX = INTX 1 IF (INTXSTART = INTX AND INTYSTART = INTY) THEN IF colx (intY) .count mod 2 <> 0 THEN INTPOS = 1 For Each Element in colx (intery) If Element = IntxStart Then Colx (inty) .remove (intPOS) Exit do END IF INTPOS = INTPOS 1 NEXT END IF Exit do END IF END IF Elseif Blingoright Then IF MBytminestatus (Intery 1, Intx) = None Thenif Intx = MintCols - 1 THEN BLNGORIGHT = FALSE Right: colx (intery) .add Intx INTY = INTY 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO While mbytminestatus (intery, intx) = none Colx (intery) .add intx IF intery = mintrows - 1 Then Goto Down INTY = INTY 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO Wend Colx (intery) .add intx BLNGOLEFT = TRUE Else INTX = INTX 1 IF (INTXSTART = INTX AND INTYSTART = INTY) THEN IF colx (intY) .count mod 2 <> 0 THEN INTPOS = 1 For Each Element in colx (intery) If Element = IntxStart Then Colx (inty) .remove (intPOS) Exit do END IF INTPOS = INTPOS 1 NEXT END IF Exit do END IF END IF Else BLNGORIGHT = FALSE BLNGODOWN = TRUE Colx (intery) .add intx INTY = INTY 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO END IF Elseif Blngodown Then Colx (intery) .add intx IF MBYTMINESTATUS (INTY, INTX - 1) = None Tan IF intery = mintrows - 1 THEN BLNGODOWN = FALSE Down: INTX = INTX - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO While mbytminestatus (intery, intx) = none IF INTX = 0 THEN GOTO LFT INTX = INTX - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO Wend BLNGOUP = TRUE Else INTY = INTY 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO END IF Else BLNGODOWN = FALSE BLNGOLEFT = TRUE INTX = INTX - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO END IF Elseif blngoleft then IF MBytminestatus (INTY - 1, INTX) = None Thenif Intx = 0 THEN BLNGOLEFT = FALSE LFT: colx (intery) .add intx IF intery = 0 THEN GOTO UP INTY = INTY - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO While mbytminestatus (intery, intx) = none Colx (intery) .add intx IF intery = 0 THEN GOTO UP INTY = INTY - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO Wend Colx (intery) .add intx BLNGORIGHT = TRUE Else INTX = INTX - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO END IF Else BLNGOLEFT = FALSE BLNGOUP = TRUE Colx (intery) .add intx INTY = INTY - 1 IF (INTXSTART = INTX and INTYSTART = INTY) THEN EXIT DO END IF END IF END IF Loop 'The location of each scan line from the new traversal collection, and opens the founded checkered in the past For y = 0 to mintrows - 1 IF colx (y) .count> 0 THEN 'Sort the x co-ord pairs in assending order, by using 'A Standard Listbox Control For x = 1 to colx (y) .count DIM INTXVALUE AS INTEGER INTXVALUE = colx (y) (x) IF INTXVALUE <10 THEN INTXVALUE = INTXVALUE 48 Elseif INTXVALUE> = 10 THEN INTXVALUE = INTXVALUE 55 END IF MFRMDisplay.lstsortedx.addItem Chr $ (INTXVALUE) NEXT 'Displaying the square between the scan start and the X coordinate of the X coordinate of the stop position in the array collection For x = 0 to mfrmdisplay.lstsortedx.listcount - 1 Step 2 DIM INTR1 AS INTEGER DIM INTC1 AS INTEGER DIM INTCOLSTART AS INTEGER DIM INTCOLEND AS INTEGER DIM INTDX AS INTEGER DIM INTWIDTH AS INTEGER INTR1 = Y * MintButtonheight INTCOLSTART = ASC (mfrmdisplay.lstsortedx.list (x)) IF INTCOLSTART <= 57 THEN INTCOLSTART = INTCOLSTART - 48 Elseif Intcolstart> = 65 THEN INTCOLSTART = INTCOLSTART - 55 END IF INTCOLEND = ASC (MFRMDisplay.lstsortedx.list (x 1)) if Intcolend <= 57 THEN INTCOLEND = INTCOLEND - 48 Elseif IntColend> = 65 THEN INTCOLEND = INTCOLEND - 55 END IF INTC1 = INTCOLSTART * MINTBUTTONWIDTH INTDX = INTCOLEND - INTCOLSTART 1 INTWIDTH = INTDX * MINTBUTTONWIDTH Mfrmdisplay.paintPicture mfrmdisplay.imgopenblocks, intc1, inv1,, 0, 0, intWidth, MintButtonHeight For i = 0 to INTDX - 1 IF MBytmarked (Y, INTCOLSTART I)> NONE THEN IF mbytmarked (y, intcolstart i) = Question Then MFRMDisplay.PaintPicture MFRMDISPLAY.IMGQUESTION, INTC1 I * MINTBUTTONWIDTH, INTR1 Else MFRMDisplay.paintPicture mfrmdisplay.imgflag, intc1 i * mintbuttonwidth, INTR1 END IF Elseif MBytminestatus (Y, Intcolstart i)> None Then MFRMDISPLAY.CURRENTX = INTC1 I * MINTBUTTONWIDTH mfrmdisplay.currenty = INTR1 IF MBytminestatus (Y, INTCOLSTART I)> = Been Then MFRMDISPLAY.FORECOLOR = QBColor (MBytminestatus (Y, INTCOLSTART I) - BEEN) MFRMDisplay.print MBytminestatus (Y, INTCOLSTART I) - BEEN Elseif MBytminestatus (Y, INTCOLSTART I) = Mine Then MFRMDisplay.paintPicture mfrmdisplay.imgbutton, INTC1 I * MINTBUTTONWIDTH, INTR1 Else MFRMDisplay.ForeColor = QBColor (MBytminestatus (Y, INTCOLSTART I)) MFRMDisplay.print MBytminestatus (Y, INTCOLSTART I) MBYTMINESTATUS (Y, INTCOLSTART I) = MBYTMINESTATUS (Y, INTCOLSTART I) BEEN END IF END IF NEXT NEXT Mfrmdisplay.lstsortedx.clear END IF NEXT End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' Description: According to the size of the form set in the game, the size of the new game main display form is displayed. ' 'Enter parameters: no 'Output parameters: no ' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Private sub resizedisplay () 'Setting the form size mfrmdisplay.scalemode = 1 MFRMDisplay.width = mfrmdisplay.width - mfrmdisplay.scalewidth mintcols * mintbuttonwidth * screen.twipsperpixelx Mfrmdisplay.height = mfrmdisplay.height - mfrmdisplay.scaleHeight MINTROWS * MINTBUTTONHEIGHT * Screen.TwipsPerpixely mfrmdisplay.lblmineSleft.Height 'Set the size of the Label control for the number of remaining mines mfrmdisplay.lblmineFT.LEFT = 0 MFRMDISPLAY.LBLMINESESEFT.TOP = mfrmdisplay.scaleHeight - mfrmdisplay.lblmineSleft.Height mfrmdisplay.lblmineSleft.width = mfrmdisplay.scaleWidth Mfrmdisplay.lblminesled = "Remaining mines:" & mbytnummines mfrmdisplay.scalemode = 3 End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' ' 'Description: As long as the left mouse button is pressed, this action is triggered, and the mouse cursor is passed in that square. This function is called in the mouse movement event of the game owner display window ' 'Enter parameters of the function: INTBUTTON: indicates which mouse button is clicked (left button or right button and middle key) 'Inx: Record the mouse button Clicked position in the coordinate of the X-axis' 'INY: Record the coordinates of the mouse button clicked on the Y-axis ' 'Return Value: Air' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public Sub TRACKHITTEST (INTBUTTON AS INTEGER, INTX AS SINGLE, INTY AS SINGLE) DIM BLNLNLEFTDOWN AS BOOLEAN 'Define a Boolean variable BLNLNLTDOWN, used to mark the left mouse button is pressed BLNLEFTDOWN = (intButton and LEFT_BUTTON> 0 'Judgment is the left mouse button 'If you press, the left mouse button is IF blnleftdown then 'If you don't click on the left button in the game, then don't do anything, exit this process IF not MblnhittestBegun kiln 'Determination of the position of the mouse click, in the previous definition, defined as the width and height of each checker, with the obtained mouse click position, with the aspect of the square, and get a mouse click. Which checkered, the first few columns in the square INTX = Int (INTX / MINTBUTTONWIDTH) Intery = int (intY / mintButtonHeight) 'If the X-axis of the mouse click is greater than the number of rows of the game effective window, 'Or the y-axis of the mouse click is greater than the number of columns of the game effective window. 'Or the x-axis of the mouse click smaller than the minimum position of the game valid window. 'Or the y-axis of the mouse click is smaller than the minimum position of the game effective window. 'The location of the mouse click has exceeded the effective window of the game. 'So I quit this process, that is, what is the action is not IF INTX> = mintcols or inty> = mintrows or intx <0 or inty <0 THEN mfrmdisplay.imgqspressed.visible = false mfrmdisplay.imgpressed.visible = false EXIT SUB END IF 'If the square clicked in the mouse has been marked as a square with mine 'So nothing, and quit this process IF mbytmarked (intX)> = flagged then mfrmdisplay.imgqspressed.visible = false mfrmdisplay.imgpressed.visible = false EXIT SUB END IF DIM Introwold As INTEGER DIM INTCOLOLD AS INTEGER 'Define two variables INTROWOLD and INTCOLOLD, used to record the position of the previous mouse click Introwold = MINTROW INTCOLOLD = MINTCOL 'Get the mouse click checkered coordinates Mintcol = Intx * MintButtonWidth MINTROW = INTY * MINTBUTTONHEIGHT 'If the current click position of the mouse is the same as the position of the previous click, then nothing does not do and quit this process. 'Unless the current click position of the mouse is different, the program continues to execute down. IF Introwold = MINTROW AND INTCOLD = Mintcol Then If mfrmdisplay.imgpressed.visible or mfrmdisplay.imgqspressed.visible kilqspressed.visible EXIT SUB END IF END IF 'If the current location of the mouse click has been opened, then nothing, exit this process If MBytminestatus (INTY, INTX)> = Been Then MFRMDisplay.imgpressed.visible = falsemfrmdisplay.imgqspressed.visible = false EXIT SUB END IF 'If the square in the mouse point is marked as the question mark, then the icon of the mouse button is displayed. IF mbytmarked (intery, intx) = Question Then mfrmdisplay.imgpressed.visible = false mfrmdisplay.imgqspressed.visible = false mfrmdisplay.imgqspressed.Left = Mintcol mfrmdisplay.imgqspressed.top = MINTROW mfrmdisplay.imgqspressed.visible = TRUE Else 'If the square in the mouse point is not marked, then the icon pressed by the mouse. mfrmdisplay.imgqspressed.visible = false mfrmdisplay.imgpressed.visible = false mfrmdisplay.imgpressed.Left = Mintcol mfrmdisplay.imgpressed.top = mintrow Mfrmdisplay.imgpressed.visible = TRUE END IF END IF End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' Description: This function is called when a CLSWINMINE type object is initialized. To initialize the variables in the game and the respective markers and from the newbrey area 'Enter parameters: no ' 'Output parameters: no '' ' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Private sub class _ initialize () 'Set the total number of matters of the current level game MBytnummines = 10 'Initialization is correctly marked as a number of mines MBYTCORRECTHITS = 0 'Initialize the total mark (including wrong tag) mbyttotalhits = 0 'The number of rows of the total landmines area MINTROWS = 8 'Initializing the total number of mine regions Mintcols = 8 'Row number of rows of mine regions that initialize the correctly marked MINTROW = -1 'Initializing the number of columns in the most labeled landmines Mintcol = -1 'Initialization starting a new game tag Mblnnewgame = false 'Initialization is correct when the mouse is correct MblnhittestBegun = false 'Initializing the game displayed main form Set mfrmdisplay = nothing 'Randomly distributed mines InitializationMinefield End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' ' 'Description: Prevent players from setting up the number of rows, columns and minensis of the unsuitable mines. And set the number of rows, columns and minensis in the appropriate range, and finally store the number of mines, the number of columns, and minens in the related properties of the game CLSWINMINE class '.' 'Enter parameters: introws: The number of rows of the settings of the mine distribution area 'Intcols: The number of columns in the set mine distribution area' 'Bytmines: The mineral number included in the set mine distribution area' 'BLNLEVELCUSTOM: If the number of rows, columns and minens of the player custom mine, then this value is set to True, otherwise the value is set to fake ' 'Output parameters: no' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public Sub SetMinefieldDimension (Introws As Integer, Intcols as INTEGER, BYTMINES AS BYTE, BLNLEVELCUSTOM AS BOOLEAN) 'Get the number of rows set in the game, compare, so that it is limited to within the appropriate range MINTROWS = INTROWS IF Introws IF introws> max_rows kilows = max_rows Mintcols = intcols IF INTCOLS IF INTCOLS> max_cols kiln mintcols = max_cols 'And ensure that the number of mines set by the player is also suitable, (of course, the specific number can be determined by itself) MBytnummines = bytmines IF BLNLEVELCUSTOM THEN DIM INTMINES AS INTEGER INTMINES = (Mintrows * MintCols) / 5 IF Bytmines MBytnummines = Intmines Bytmines = INTMINES Elseif Bytmines> (INTMINES * 4) / 3 THEN MBYTNUMMINES = (INTMINES * 4) / 3 Bytmines = MBYTNummines END IF END IF IF Bytmines If BYTMINES> MAX_MINES THEN MBYTNUMMUMMINES = max_mines' Clears the display of the current window and start a new game mfrmdisplay.cls 'According to the size of the mine map set in the game, adjust the size of the display main window. ResizeDisplay End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * '' 'Description: When the instance object of the game CLSWINMINE type is set to be empty, call this function, which is the destructor of the class. 'The memory space used to release the dynamic arrays used in the game, and the memory space of the error mark mine position is vacated. '' ' 'Enter parameters: no '' ' 'Output parameters: no' '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' Private sub coplass_terminate () 'When the type clswinmine is destructed, release the memory space of three arrays ERASE MBYTMINESTATUS ERASE MBYTMARKED ERASE MBYTMINELOCATIONS DIM I as integer 'Defines the number of loops 'Sprinkling the memory space of the misunderstand position For i = 1 to MCOLWRONGLOCATIONS.COUNT McOLWRONGLOCATIONS.REMOVE 1 NEXT End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'Winmine. FRM: This is the game display winner window, she is a main interface interface with players to interact and entertain, and it' also shows the use of WinMine. CLS class instance in the game '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'Objects of a CLSWINMINE class declared in a general module and name it Objmine. And Objmine objects have All attributes of the 'CLSWINMINE class (that is, variables), method (that is, functions) Private Objmine As New CLSWINMINE 'The main form is loaded, the following events: Private sub flow_ load () 'Through the Objmine object, give the value of the FRMDisplay property of the CLSWINMINE class to which it belongs is given to set the game's main window. 'The mouth is the current window, so the current window can change the window's display set objmine.frmdisplay = me as the game progresses End Sub 'Menu new game code: Private sub mnunew _ click () 'Ready to start a new game. Objmine.newgame 'calls the newgame method of the Objmine object, starting a new game. End Sub 'Select the game level in the main form to trigger this event when the level level is primary. Private sub mnubeginner _ click () 'Painting the primary horizontal level in the game level (you will choose) Mnubeginner. checked = true 'Cancel the hook before the remaining three levels of the game level (you don't choose it) MnuinterMediate. Checked = false Mnuexpert. Checked = FALSE Mnucustom. Checked = FALSE 'Setting the buried light in the main form of 8 * 8, including 10 thunders, primary levels Objmine.SetMinefieldDimension 8, 8, 10, False 'And start a level of new games set Objmine.Mblnnewgame = TRUE End Sub 'Select the game level in the main form to trigger this event when the game level is intermediate level. Private sub mnuintermediate_click () Mnubeginner.checked = false MnuinterMediate.checked = TRUE Mnuexpert.checked = false Mnucustom.checked = false 'Set the size of the mine distribution area in the game to the intermediate level, and prepare to start a new game Objmine.SetMinefieldDimension 16, 16, 40, false Objmine.Mblnnewgame = TRUE End Sub 'Select the game level in the main form to trigger this event when the game level is advanced. Private sub mnuexpert_click () Mnubeginner.checked = false MnuinterMediate.checked = false Mnuexpert.checked = true Mnucustom.checked = false 'Set the size of the mine distribution area in the game to the expert level, and ready to start a new game Objmine.SetMinefieldDimension 16, 30, 100, false Objmine.Mblnnewgame = TRUE End Sub 'Select the game level in the main form to customize this event, this event can make the user to determine how much Tibet map is to play and set how many thunders have been hidden. Private sub mnucustom _ click () 'Painting the custom horizontal of the game level to the hook (you will choose) 'Cancel the hook before the remaining three levels of the game level (you don't choose it) Mnubeginner.checked = false MnuinterMediate.checked = false Mnuexpert.checked = false Mnucustom.checked = true 'Get the size of Tibetan thunder when the game is played, and the number of Tibetan thunders 'And the resulting ranking position size when the result is performed, and the number of Tibetan thunders is used as the default value of the corresponding input box in the custom form. Objmine.getminefieldDimensions frMCustomDLG FRMCUSTOMDLG.SHOW 1 'Displays Custom Forms of Custom Size and Lights' If in the custom form, press the left corner Escape key in the keyboard, then exit the custom form Iffrmcustomdlg.mblnescape1en exit sub 'If you click the sure button in the custom form, then you will re-establish a new mine-mine game in the size of the Tibet map set in the custom form. Objmine.SetMinefieldDimension Val (frMcustomdlg.txtrows), Val (frmcustomdlg.txtColumns), Val (frmcustomdlg.txtmines), TRUE 'And release custom forms Unload frmcustomdlg 'According to the setting, start a new game Objmine.Mblnnewgame = TRUE End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'The following is the related code added in the custom form: Custdlg. Frm: This is a custom game level form, when clicking on the custom menu in the main form, this dialog is mode State display, so you must make a selection, otherwise you can't return to the game real-world main window to play " '$ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' Option expedition 'Define a Boolean variable to mark whether or not to press the ESC button in the custom window. If you press the ESC button, then nothing, directly exit dialog Public MBLNESCAPE AS BOOLEAN Private subdesscape_click () 'When the ESC button is pressed, the settings in this dialog will not be saved, so exit the dialog window. 'And set the variable MBLNESCAPE as true MBLNESCAPE = TRUE Unload me End Sub Private sub cmdok_click () 'When the determination button on the dialog is pressed, you exit the dialog window, but the value set will be saved to the corresponding variable. Me.hide End Sub Private sub flow_load () The initialization variable MBLNESCAPE is fake when the window is loaded. MBLNESCAPE = FALSE End Sub Private Sub Form_Unload (Cancel AS Integer) When the window memory is released, set the variable MBLNESCAPE as true. MBLNESCAPE = TRUE End Sub PRIVATE SUB TXTCOLUMNS_GOTFOCUS () 'When the line number text box in the Settings dialog is focused, then the text is selected so that it is highlighted. TXTCOLUMNS.SELSTART = 0 TXTCOLUMNS.SELLENGTH = LEN (TXTCOLUMNS) End Sub PRIVATE SUB TXTMINES_GOTFOCUS () 'When the number of mines in the setup dialog gaves the focus, then the text is selected so that it is highlighted. TXTMines.SELSTART = 0 TXTMines.Sellength = len (txtmines) End Sub Private sub TXTROWS_GOTFOCUS () 'When the column text box in the Settings dialog is focused, then the text is selected so that it is highlighted. TXTROWS.SELSTART = 0 TXTROWS.SELLENGTH = LEN (TXTROWS) End Sub 'Operation method: Private Sub Form_MouseDown (Button As Integer, Shift As Integer, x as single, y as single) 'When the left mouse button is pressed, this event is sent, call the CLSWINMINE's BeginHitTest process to determine the position of the click. Objmine.beginhittest Button, X, Y End Sub Private Sub Form_Mousemove (Button As Integer, Shift As Integer, x as single, y as single) 'When the left mouse button is pressed, and after a location, this event is sent, the TrackHitTest process of the Clswinmine class is called to determine the location of the passenger. Objmine.trackhittest Button, X, Y End Sub Private Sub Form_MouseUp (Button As Integer, Shift As Integer, x as single, y as single) 'When the left mouse button bounces, this event is sent, call the clswinmine class' s TrackHitTest process to determine the position of the mouse bomb. Objmine.endhittest Button, X, Y End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'Add a Bout dialog The picture below is the running result of our dialog, where we joined a security button (set its CAPTION attribute as cmdok), and a tab control (set its CAPTION property empty, because we have dynamically in the code The settings). The following is the main code: Drawing About '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' '= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 'Cmdok _ click () event is the meaning of the form memory when the statement unload me occurs when the button is clicked. '= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Private sub cmdok _ click () Unload me End Sub '= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = The 'form _ load () event occurs when "About" in the menu is to load the form into memory. '= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Private sub flow_load () DIM HCHH AS STRING 'Defines a string Hchh = chr $ (13) & chr $ (10) 'and set it to the carriage return DIM ABOUTMESSAGE AS STRING 'Defines a message string to display relevant information about information. AboutMessage = Hchh & Hchh & "Producer: 潇" & hchh AboutMessage = AboutMessage & "April 2004" LBLABOUT.CAPTION = AboutMessage 'Display information on the label End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'Add the "About" menu in the main form and add a call code for the form in the code window of the main form: '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' Private sub mnuaboutwinmine _ click () 'Display "About" dialog FRMaboutBox.show 1 End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'Add a "Game Rules Description" menu in the main form, and add a call code for the game rules in the code window of the main form: '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' Private sub mnuplayinginstructions_click () 'Display the game rule note form FRMinstructBox.show 1 End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'The following is the code added to the form of the game rules: 'When you click the OK button in the Function Description Form, release the current game rule description Form' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' Private sub cmdok _ click () Unload me End Sub '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' 'When the game rule describes the description of the window, these instructions are defined in the youxiguize variable. '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' Private sub flow_load () Dim hhhc as string HHHC = CHR $ (13) & chr $ (10) Dim youxiguize as string YouXiguize = CRLF & "Press F2 to start a new game." & CRLF & CRLF Youxiguize = youxiguize & "The goal of this game is to try the way to mark the game in the game in the game." Youxiguize = youxiguize & "In the game you can see that the number of mines contained around 8 squares have been opened in the square, to determine the random distribution of the remaining lights." Youxiguize = youxiguize & "If you have opened a checkered in the game, then you have failed, and the game is over." Youxiguize = youxiguize & "If you are open in the game is a checkered in the game, then you can judge the surrounding mines through this number, because this number is the mine number contained around 8 squares" Youxiguize = youxiguize & "You can right click on a checkered position at this time, it will display a flat banner in this checkered position. It means that you are determined here as a mine." Youxiguize = youxiguize & "If you click on the mouse button again in a checkered checker, then you will display a question mark icon, indicating that you can't determine if there is a mine; if you At this location, click the right mouse button, then a normal checkered button will be displayed to restore the initial state. " YouXiguize = youxiguize & "When you can't determine if there is a landmine, then this question mark is a useful help, you can think about this place with another return." Youxiguize = youxiguize & "You can also click the right mouse button directly twice directly, then it will also display a question mark icon in this location." Youxiguize = youxiguize & "Of course, if you want to play, we must click the left mouse button, so if there is no mine in the position, you will open this position, and display a surrounded 8 squares included. Number. " Txtinstruct. Text = youxiguize End Sub