VisualBasic5.0 is becoming more and more popular among programmers because of its visual programming method. We can use VisualBasic5.0 to write multimedia software with beautiful interfaces and beautiful music. However, you may encounter some problems that are difficult to solve during the actual programming process. The following are some of the author's experiences in multimedia creation, which may enrich your multimedia accessory box.
1. Background music
When using Visual Basic 5.0 to compile applications, we can use the OLE nesting method to easily add background music to an application.
Enter the VisualBasic5.0 system environment and create a new form. Click on the 'OLE Container' on the 'Form Control' and drag it anywhere in the FORM. Select 'Media Clip' in the 'Insert Object' window, select the 'Show as icon' column (this column must be selected, otherwise it cannot be hidden), and press the 'Confirm' key to exit.
In the 'Media Player' window, select 'File', 'Open', and select the sound file you want to use as background music from the file list. Since music files are generally not very long, they require loop playback, which can be achieved by setting the 'media player' to play repeatedly. Then select 'Options' in the 'Edit' menu, select 'Repeat Play' in the options window and remove the check mark in front of 'Replay Control Bar', confirm and exit.
Return to the Visual Basic 5.0 system environment, press the right button of the mouse, and click the 'Properties' column in the pop-up menu to bring up the properties window. Select the 'Ole1' object and set its 'Visible' property to .F. and its 'Autosize' property to .F.. Press the right button of the mouse again, click the 'Code' column in the pop-up menu to enter the process writing window, and write the 'Load' process of the 'Form1' object:
PRivateSubForm_Load()
OLE1.DoVerb(0)
EndSub
4. Press the 'F5' key to run.
2. Transparent effect three-dimensional button
When making multimedia software, we sometimes need three-dimensional buttons with transparent effects. We can use the combination of label (LABEL) and shape (SHAPE) to complete this design.
Enter the Visual Basic 5.0 system environment, create a new form (FORM1), and set the Picture property of FORM1 to a WINDOWS bitmap file (.BMP).
Click "Shape" in the "Form Control Bar" and pull out a rectangular box (SHAPE1) on FORM1. Create SHAPE2, SHAPE3 and SHAPE4 in the same way. Set the properties of these four SHAPEs as follows in the properties window:
SHAPE1:
BorderColor=&HFFFFFF
BorderWidth=3Left=2160
Top=2040Width=1100
SHAPE2:
BorderColor=&H80000008
BorderWidth=3Left=2160
Top=2520Width=1100
SHAPE3:
BorderColor=&HFFFFFF
BorderWidth=3Left=2160
Top=2040Height=500
SHAPE4:
BorderColor=&H80000008
BorderWidth=3Left=3240
Top=2040Height=500
Click the "Label" in the "Form Control Bar" with the mouse, pull out a rectangular box (LABEL1) on FORM1, and adjust its size to fit into the four SHAPEs. Set its property Caption to the title of the customized button, Alignment to 2, and Backstyle to 0.
Double-click LABEL1 and write the MouseDown process and MouseUp process of LABEL1 as follows:
PrivateSubLabel1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
Shape1.BorderColor=&H80000008
Shape3.BorderColor=&H80000008
Shape2.BorderColor=&HFFFFFF
Shape4.BorderColor=&HFFFFFF
Label1.Top=Label1.Top 10
EndSub
PrivateSubLabel1_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
Shape1.BorderColor=&HFFFFFF
Shape3.BorderColor=&HFFFFFF
Shape2.BorderColor=&H80000008
Shape4.BorderColor=&H80000008
Label1.Top=Label1.Top-10
EndSub
Just press the 'F5' key to run it.
3. Mobile subtitles
On TV, we often see a line of prompt text or advertising information moving from right to left at the bottom of the screen, which not only serves as a prompt but does not damage the entire screen. We can also complete this design in VisualBasic5.0.
Enter the Visual Basic 5.0 system environment, create a new form (FORM1), and set the Backcolor property of FORM1 to an RGB (192,192,192).
Click the "Label" in the "Form Control Bar" with the mouse, and pull out a rectangular box (LABEL1) on FORM1. Set its properties Caption to "Active Subtitle Demonstration", Autosize to .T., Backstyle to 0, Forecolor to RGB (128, 128, 128), Fontname to "official script", Fontbold to .T., and Fontsize to 36.
Click LABEL1 with the mouse, press the CTRL C (copy) key, and then press the CTRL V (paste) key to create another label (LABEL2) with the same title as LABEL1 on FORM1, and set its Forecolor attribute to RGB (255, 255, 0 ). Adjust the position of LABEL2 so that it is just higher than LABEL1, so that LABEL1 looks like the shadow of LABEL2.
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 200.
Double-click FORM1 and write the Load process of FORM1 as follows:
PrivateSubForm_Load()
Label1.Left=Width 50
Label2.Left=Width
EndSub
6. Double-click TIMER1 and write the Timer process of TIMER1 as follows:
PrivateSubTimer1_Timer()
IfLabel1.Left<0-Label1.WidthThen
Label1.Left=Width 50
Label2.Left=Width
EndIf
Label1.Left=Label1.Left-500
Label2.Left=Label2.Left-500
EndSub
7. Press the 'F5' key to run and you will see the subtitles appear from the right side of the screen and disappear when moved to the far left of the screen.
4. Fade in and out of text
The commentary subtitles at the beginning of many games and the creative credits after the explosion use the character fade-in and fade-out method. Text with fade-in and fade-out effects can also be produced in Visual Basic 5.0.
Enter the Visual Basic5.0 system environment and create a new form (FORM1).
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 "Fade in and out of text", Autosize to .T., Backstyle to 0, text color to RGB (0,128,128), font to "official script", Fontbold to .T., and font size to 36.
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 Interval property to 100 and its Enabled property to .F..
Click the "Command Button" in the "Form Control Bar" and pull out a rectangular box (COMMAND1) on FORM1. Set its property Caption to "Start".
Double-click COMMAND1 and write the Click process of COMMAND1 as follows:
PrivateSubCommand1_Click()
IfTimer1.Enabled=FalseThen
Timer1.Enabled=True
EndIf
EndSub
Double-click FORM1 and write the Activate process of FORM1 as follows:
BackColor=RGB(0,128,128)
I=0
7. Double-click TIMER1 and write the Timer process of TIMER1 as follows:
PrivateSubTimer1_Timer()
I=I 10
IfI>=255*2Then
Timer1.Enabled=False
I=0
EndIf
IfI>=255Then
Label1.ForeColor=RGB(255*2-I,128,128)
Else
Label1.ForeColor=RGB(I,128,128)
EndIf
EndSub
Press 'F5' key to run. Click the "Start" button with the mouse, and you can see that the title gradually changes from the background color to red, and then from red to the background color.
The above programs all run successfully in Visual Basic 5.0 and WINDOWS95. ->