[ATTACH]2303[/ATTACH]
Now click on Resources in the list to the left:
[ATTACH]2304[/ATTACH]
If you have made it right you should now see something like this:
[ATTACH]2305[/ATTACH]
Adding Resources
The easiest way to add a resource is to do import it from a file, to do this click at "Add Resource" and then "Add Existing File...". Now select your file(s) and it will be added, observe that the resources will be sorted by type so if you don't find the one you added you have to change the type in the top left corner. After adding some resources it could look like this:
[ATTACH]2306[/ATTACH]
Using Resources
To access the resources you write My.Resources.[the resource's name], like this:
[highlight=VB.NET] My.Resources.test1[/highlight]
So this will give us the Resource called test1. To use it we can do something like this:
[highlight=VB.NET] Me.BackgroundImage = My.Resources.test1[/highlight]
but if we only do this it doesn't seem so useful since we could just have added the image to be the background of the form in the design view, but if we want to have different backgrounds, like this:
[highlight=VB.NET] Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Select Case Now.Minute
Case Is < 15
Me.BackgroundImage = My.Resources.test1
Case Is < 30
Me.BackgroundImage = My.Resources.test2
Case Is < 45
Me.BackgroundImage = My.Resources.test3
Case Is < 60
Me.BackgroundImage = My.Resources.test4
End Select
End Sub[/highlight]
You've probably already got the idea. If you want to get one of the resources you've already added to be able to modify it or something similar you can find it in your project folder in the sub folder called resources.
That was everything about resources in VB.NET, hope you've learned something and understood why it's good to use them. :)


Sign In
Create Account



Back to top









