Visual Basic

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingVisual Basic

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old April 4th, 2010, 07:07 PM
amiley amiley is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2010
Posts: 1 amiley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 46 sec
Reputation Power: 0
Exclamation Help needed with generating random images

hi i am completely new to visual basic and do not know much code so any help will be much apprieciated basically i am trying to do have a command button and every time you click it, it randomly changes a picture in picturebox/imagebox so that everytime it is completely random picture.

so far i have imagelistbox1 with all my images in, commandbutton1 and picturebox1 but cannot work out any code to allow me to do what i would like to do.

please help this is a project for college and i am rapidly running out of time, many thanks in advance

Reply With Quote
  #2  
Old June 25th, 2010, 04:45 PM
Ash.Burlaczenko Ash.Burlaczenko is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jun 2010
Posts: 3 Ash.Burlaczenko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 36 sec
Reputation Power: 0
Hi amiley

You problem seams pretty simple. VB has a an class called Random. Random has a function which is passed an integer and returns a random number from 0 to the integer that was passed to it.

Here is a brief guide -

Create the Random object
Create an integer to store the number of pictures
Create an integer to store the random number
Use the random number to get the filename from the listbox
Set the picturebox to image to the file

Some sample code -

Dim myRandom as New Random
Dim imageCount as Integer
Dim randomNum as Integer
Dim filename as String

imageCount = myListBox.Items.Count
randomNum = myRandom.Next(imageCount-1)
filename = myListBox.Items.Item(randomNum)
myPictureBox.Image = Image.FromFile(filename)

Hope this helps. Good luck at college.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingVisual Basic > Help needed with generating random images


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap