I want to be able to randomly choose a picture of a student from hundreds of possible ones and display it in a picture box.
Using "Select Case intRndStudent" works fine when tested for 14 students
but the code will be incredibly long and adding another picture is a choreCode:Select Case intRndStudent Case 1 picStudent.Image = My.Resources.1 Case 2 picStudent.Image = My.Resources.2
I want to use a variable but I can't get it to work.
Would someone please tell me why this does not work and how to make it work?Code:intRndStudent = Int(Rnd() * intNumPics) + 1 ' choose a picture at random txtOutput.Text = intRndStudent ' used to check that random number is being chosen correctly picStudent.Image = My.Resources.intRndStudent ' this code is bad - Error 1 'intRndStudent' is not a member of 'Resources'.




Reply With Quote