0% found this document useful (0 votes)
45 views4 pages

Private Sub Button1

The document contains code for handling button clicks to change the background image of a form, including saving the selected image path to user settings. It includes code to load the last selected background image from settings on form load. There is also code to allow selecting a new background image and resetting to the default by clicking buttons, while saving the selection to settings.

Uploaded by

orkeed ghanem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

Private Sub Button1

The document contains code for handling button clicks to change the background image of a form, including saving the selected image path to user settings. It includes code to load the last selected background image from settings on form load. There is also code to allow selecting a new background image and resetting to the default by clicking buttons, while saving the selection to settings.

Uploaded by

orkeed ghanem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles

Button1.Click
If ColorDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel
Then
Label1.ForeColor = ColorDialog1.Color
End IfEnd Sub

1.
ofd.ShowDialog()
2.
3.
Dim bgimage As String = ofd.FileName.ToString()
4.
5.
Me.BackgroundImage = New System.Drawing.Bitmap(bgimage)
6.
1.
My.Settings.setBGImage = bgimage
2.
3.
My.Settings.Save()
4.

1.
If My.Settings.setBGImage = "" Then
2.
3.
'
4.
5.
Else
6.
7.
Me.BackgroundImage = New
System.Drawing.Bitmap(My.Settings.setBGImage)
8.
9.
End If
10.

1.
Public Class Form1
2.
3.
    Private Sub NewBG_Click(sender As System.Object, e As
System.EventArgs) Handles NewBG.Click
4.
5.
        OpenFileDialog1.ShowDialog()
6.
7.
        If OpenFileDialog1.FileName <> "" Then
8.
9.
            Form2.BackgroundImage =
Image.FromFile(OpenFileDialog1.FileName)
10.
11.
            My.Settings.BGImageUser = OpenFileDialog1.FileName
12.
13.
            My.Settings.Save()
14.
15.
        End If
16.
17.
    End Sub
18.
19.
 
20.
21.
    Private Sub DefaultBG_Click(sender As System.Object, e As
System.EventArgs) Handles DefaultBG.Click
22.
23.
        Form2.BackgroundImage =
Image.FromFile(My.Settings.BGImage)
24.
25.
        My.Settings.BGImageUser = My.Settings.BGImage
26.
27.
    End Sub
28.
29.
 
30.
31.
    Private Sub Form1_Load(sender As System.Object, e As
System.EventArgs) Handles MyBase.Load
32.
33.
        Form2.Show()
34.
35.
    End Sub
36.
37.
End Class
38.

1.
Public Class Form2
2.
3.
    Private Sub Form2_Load(sender As System.Object, e As
System.EventArgs) Handles MyBase.Load
4.
5.
        If My.Settings.BGImageUser = "" Then
6.
7.
            Me.BackgroundImage =
Image.FromFile(My.Settings.BGImage)
8.
9.
        Else
10.
11.
            Me.BackgroundImage =
Image.FromFile(My.Settings.BGImageUser)
12.
13.
        End If
14.
15.
    End Sub
16.
17.
End Class
18.

Move

myPictureBox.Left += deltaX;
myPictureBox.Top += deltaY;
Random rnd1 = new Random();private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;

int x = rnd1.Next(0, Width - pictureBox1.Width);


int y = rnd1.Next(0, (Height - 28) - pictureBox1.Height);

pictureBox1.Location = new Point(x, y);

timer1.Enabled = true;
}

Sound

'add a media player

Dim Player As WindowsMediaPlayer = New WindowsMediaPlayer

'assign the location of the song to be played

Dim SongLocation = "D:\Music\Single\Skrillex 2 Hours HQ Longest On Youtube).mp3" 'any song you want to play

'play the song

Player.URL = SongLocation

Player.controls.play()

You might also like