Hi everyone. I'm new in Visual Basic(i work in Visual basic 2010) and i have a problem and hope u will help me. I want to load image to pictureBox depending on randomly generated number. For example if random number is 14 then i want to load image with the file name "14.gif".random number is generated when button "Generate" is clicked. how can i do that? images are in Resources folder inside the project folder.
I tried this but didnt work:
Public Class Form1
Dim images() As String Dim RandClass As Random = New Random Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load images = IO.Directory.GetFiles(My.Resources, "*.gif") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim R As Integer = RandClass.Next(0, images.Count) PictureBox1.Image = Image.FromFile(images(R)) End Sub
Edited by Reverend Jim: title typo