XY52 code finishing and analysis

xiaoxiao2021-03-06  80

General Statement: Private Carprice (0 to 9) As longprivate carname (0 to 9) AS STRINGPRIVATE CURRENTCAR AS INTEGER

-------------------------------------------------- -----------------------------------------------

The Private Sub CM1_Click () game starts, setting the "OK" button to make the text box get focus cm2.enabled = trueText1.setfocusrandomizercrar = int (10 * rND) 'Generate random number between 0 to 9. . Label4.caption = carname (currentcar) DIM INTTEMP AS INTEGERFOR INTTEMP = 0 to 9 img (intTemp) .visible = false Next IntTemp Img (CurrentCar) .visible = true

End Sub

Private Sub CM2_Click () DIM TEMPPRICE AS long 'If an input error occurs, jump to the error handling segment

Tempprice = clng (Text1.Text) on Error Goto InputErrorf Temppprice <0 THEN

MsgBox ("Do you want me to pour money?") Elseif (Tempprice> carprice (currentcar) THEN MSGBOX ("High!` `") ThenMsgBox "is low!" "Else Msgbox" Congratulations! ~ Answer! ~! "" Cm2.enabled = false end if "empty the text file and makes it focus. Text1.SetFocus Text1.Text = "" Exit Sub ----------------- enter the wrong target when exiting the event did not occur. InputError: msgbox "Enter an error, it is possible to enter positive integers! ~ !!" text1.text = "" text1.setfocus end SUB

Private sub cm3_click () unload me

End Sub

Private Sub Form_Load () 'Initializing the Name and Price Carname (0) = "The car" carname (1) = "CARNAME" carname (2) = "carname (2) =" carname (2) = "carname (2) =" "Carname (3) =" The car "carname (4) =" 家 车 车 "carname (5) =" 俺家 来 来 车 车 "carname (6) =" 俺家 来Car "carname (7) =" CARNAME (7) = "CARNAME (8) =" Carname (9) = "CARNAME (9) =" Carten

carprice (0) = 100000carprice (1) = 207688carprice (2) = 88888carprice (3) = 122588carprice (4) = 56789carprice (5) = 54117carprice (6) = 150027carprice (7) = 308888carprice (8) = 24357carprice (9) =
< "" Elseif Keyascii = VBKEYRETURN THEN CM2_CLICK ------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ---------------------------------- Knowledge point: 1 control array. 2 Random. 3 Simple operation of the button.

I feel that the control array is still very easy to use, the same type of control, can edit the unified attribute together, but you can also edit it first, then copy paste. The key is that in the code, the control array is called with the for loop, and the efficiency is high, hehe.

Is Randomize is not Random, this thing, very practical, tomorrow taking time is familiar with this.

CM2_Click ------------------------- Call control event

'If an input error occurs, jump to the error handling section temppprice = clng (Text1.text) on Error Goto InputError

This is the typical in-depth type does not match. Of course this error is a function prompt. I have been wondering, how can this program add an ON Erro Goto statement, can it monitor an error? It is definitely a prompt, here is the function run, if there is a problem, there will be prompts.

转载请注明原文地址:https://www.9cbs.com/read-94953.html

New Post(0)