The sweepstakes are not uncommon in life, and we have added a lot of fun to our daily life. Here you will introduce you to a very familiar computer simulation lottery game, just like a lot of lottery modes. The results of the lottery program are convenient and intuitive. All staff can clearly watch the whole process of draw. Align = "marginwidth =" 0 "marginheight =" 0 "src =" http://images.chinabyte.com/adjs/iframe-pip/y-software-pip.html "frameborder =" 0 "width =" 360 "Scrolling =" no "height =" 300 "> First, the design interface opens VB first, and the six command buttons are defined in Form1, which are used to display the numbers of the winning number. By default, the number of participants should be less than 100,000 (of course, the range of the number of lottery people can be expanded or narrowed by increasing or decreasing the number of buttons). Add two command buttons, one set to "OK" button, when pressed, the winning number is displayed. The other is set to "Continue" button, let the counter continue scrolling after selecting the winning number until the "OK" button is pressed again (the interface is as follows). Create a form of form2, add a text input box, a command button, a label. Its text box is used to enter the number of people participating in this event; the command button is used to determine and verify whether the input string is legal; the label is used to display the number of participants in this event. This program calls the system random function RND to implement the random generation of the number, define the function quWei () to display the number of numbers, through text input in Form2, to limit the maximum number of scrolling. The specific code is achieved as follows:
Private submmand1_click () if text1.text = "" The exit sub text1.setfocus End if "If it is empty, you will be re-entered. If LEN (TEXT1.TEXT)> 5 THEN MSGBOX "Tips", Vbokonly, "You entered the value" text1.text = "": text1.setfocus exit subside if "If too big, then re-enter the IF INT1.TEXT <6 THEN MSGBOX "Tips", Vbokonly, "The value you entered is too small" text1.text = "": text1.setfocus exit subside if f, if it is too small, re-enter Form2. Hide 'Close Form2 Form1.show' Open Form1 Load Mend Sub Private Sub Text1_Keypress (Keyascii As INTEGER) IF NOT (48 <= Keyascii and Keyascii <= 57) THEN IF Keyascii <> 8 Then Keyascii = 0 'Fault tolerance, make input Integer value END if End Ifend Sub