Results 1 to 2 of 2

Thread: Random Picture Slide show in VB 2010

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2012
    Posts
    1

    Unhappy Random Picture Slide show in VB 2010

    Hello,
    I'm a 100% newbie to programming, and have this project that i'm working on this project in which i have to select 3 pic and have to modes in the program "fixed" and
    "random" in the FIXED mode i let the user input the number of cycle he/she wants in the slide show of the the 3 pic that will be showing in the groupbox. and for the
    RANDOM mode, the user can select the starting pic same like fixed mode and than in start the slide show in a random location within the groupbox for ea picture. This picture shows for 2sec and changes to the next one.

    for the project we need to have One Procedure and one Function.. the procedure I have figured out but the function part im having trouble with
    the Function will be used whenever you need to generate a random number for the random mode. WHICH I DONT KNOW HOW TO DO

    also i dont know how to do the loops order for ea picture, by that i mean how do i work the timer so that the picture changes every 2sec to the next picture in the groupbox.

    I have attached the "picture viewer" how it should turnout at the end if everything is well planed but I do know how to make it work like it working in that attachment.

    the codes i have so far are this please help me figure this out :

    Public Class Form1

    Private intSeconds As Integer
    Sub ViewerReset()

    End Sub
    Function RandomNumberGen(ByVal lowSeed As Integer, ByVal highSeed As Integer) As Double

    End Function

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    cboSelection.Items.Add("Sun Flower")
    cboSelection.Items.Add("Long Water Fall")
    cboSelection.Items.Add("Water Fall Wallpaper")

    End Sub

    Private Sub btnStartStop_Click(sender As System.Object, e As System.EventArgs) Handles btnStartStop.Click
    If btnStartStop.Text = "Start" Then
    btnStartStop.Text = "Stop"
    Else
    btnStartStop.Text = "Start"

    End If
    If radFixed.Checked = True Then
    btnStartStop.Enabled = False
    btnReset.Enabled = False

    End If
    If radRandom.Checked = True Then
    btnReset.Enabled = False
    End If
    End Sub

    Private Sub tmrSeconds_Tick(sender As System.Object, e As System.EventArgs) Handles tmrSeconds.Tick
    intSeconds += 1

    End Sub

    Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
    'close the form
    Me.Close()

    End Sub

    Private Sub GroupBox1_Enter(sender As System.Object, e As System.EventArgs) Handles GroupBox1.Enter

    End Sub

    Private Sub cboSelection_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboSelection.SelectedIndexChanged
    Select Case cboSelection.SelectedIndex
    Case 0
    picSunFlower.Visible = True
    Case 1
    picSunFlower.Visible = False
    picLongWaterFall.Visible = True
    Case 2
    picSunFlower.Visible = False
    picLongWaterFall.Visible = False
    picWaterFallWallpaper.Visible = True
    End Select
    End Sub

    Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click
    ViewerReset()

    End Sub
    End Class
    Attached Files Attached Files

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Random Picture Slide show in VB 2010

    Whenever you need something random, that basically means that you use the Random class. Create an instance and assign it to a member variable. Make sure that you do not create multiple instances and use them once each. Create one instance and use it multiple times. Each time you need a random number, you call its Next method. There are lots of examples around.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width