How can I modify this in visual basic express to produse a random image instead of a random colour :-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim colornum As Integer
colornum = Int(Rnd() * 5)
Select Case colornum
Case Is = 0
Label1.BackColor = Color.Red
Case Is = 1
Label1.BackColor = Color.Yellow
Case Is = 2
Label1.BackColor = Color.Green
Case Is = 3
Label1.BackColor = Color.Blue
Case Is = 4
Label1.BackColor = Color.Orange
How can I modify this in visual basic express to produce a random image instead of a random colour?
This works in VB.net, not sure what "visual basic express" is.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim colornum As Integer
colornum = Int(Rnd() * 5)
Select Case colornum
Case Is = 0
Label1.Image = Label1.Image.FromFile("%26lt;path and filename%26gt;")
Case Is = 1
Label1.Image = Label1.Image.FromFile("%26lt;path and filename%26gt;")
Case Is = 2
Label1.Image = Label1.Image.FromFile("%26lt;path and filename%26gt;")
Case Is = 3
Label1.Image = Label1.Image.FromFile("%26lt;path and filename%26gt;")
Case Is = 4
Label1.Image = Label1.Image.FromFile("%26lt;path and filename%26gt;")
Where each case is a different image.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment