There are all kinds of neon lights flashing in the urban night. Among them, the most commonly used ones are probably the running water lights. Its flowing effect brings vitality to the quiet night. What kind of effect would it have if we added a string of sparkling water lights to the interface of the multimedia software we created? Follow the steps below to add a string of running water lights with a chasing effect to your multimedia program.
1. Create a new form. Enter the Visual5asic4.0 system environment, create a new form (FORM1), and set the Backcolor property of FORM1 to RGB (192,192,192).
2. Build the first lantern. Click the "Label" in the "Form Control Bar" with the mouse, and pull out a rectangular box (LABEL1) on FORM1. Set its attribute Caption to "★" (it can also be other characters, the "★" here can be found in the "Character Map" of "Accessories" of WINDOWS95), Autosize to .T., Backstyle to 0, and Forecolor to Red, font size 18.
3. Create other 29 lanterns. Click LABEL1 with the mouse, press the CTRL C (copy) key, and then press the CTRL V (paste) key to create another label (LABEL1 (1)) with the same title as LABEL1 on FORM1. Select 'YES' when prompted on the screen whether to create a control array. '. Repeat this copying to create a total of 30 labels, and arrange these 30 labels into a rectangular box in order.
4. Create a timer. Click "Timer" in the "Form Control Bar" with the mouse, and then click once on FORM1 to create a timer (TIMER1) on FORM1. Set its property Interval to 400.
5. Double-click FORM1 and write the Load process of FORM1 as follows:
PRivateSubForm_Load()
I=0
Forj=0To9
Label1(j*3).ForeColor=&HFF&'red
Label1(j*3 1).ForeColor=&HFF00&'green
Label1(j*3 2).ForeColor=&HFFFF&'yellow
Nextj
EndSub
6. Double-click TIMER1 and write the Timer process of TIMER1 as follows:
PrivateSubTimer1_Timer()
IfI=30Then
I=0
EndIf
I=I 1
ForJ=0To29
Label1(J).Visible=False
NextJ
IfIMod3=2Then
ForJ=0To9
Label1(J*3 1).Visible=True
NextJ
Else
IfIMod3=0Then
ForJ=0To9
Label1(J*3 2).Visible=True
NextJ
Else
ForJ=0To9
Label1(J*3).Visible=True
NextJ
EndIf
EndIf
EndSub
After running the form, you can see that the red, green, and blue lights alternately light up. Adjusting the Interval attribute value of Timer1 can change the cycle speed of the three groups of lights.
The above program runs successfully in VisualBasic5.0 and Windows95. ->