Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Help needed! How to randomize progress bar value increases.

$
0
0
Hello,

I am a 16 year old Junior in grade 11 working on a my computer programming class culminating project. I decided to do a racing rpg game since the concept is fairly simple but can be vastly expanded upon. I am not very far into the project however as it was just started today. Right now I am working on a loading screen for the program (which isn't actually a loading screen, it is just supposed to look like one) and I have a few elements on the form as well as a progress bar. What I am currently stuck on is how to make the progress bar "load" at a random rate so that it doesn't look like I just slapped a timer on the page had the prgress bar load under the 'time.tick' function. Here is the beginning portion of my code:


Code:

Public Class RacePG


    'array creates a number of images that will take frames for an animation loop
    Dim loadAnimate(3) As Image

    'this boolean will start the animation
    Dim loadAnimation As Boolean

    'ndx represents "index"
    Dim ndx As Integer

    'progress bar control variables
    Dim speed1 As Integer = 1
    Dim speed2 As Integer = 2

    Dim barLoad As Integer = 0
    Dim rndAdd As Random




    Private Sub tmrLoadAnimate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLoadAnimate.Tick

        'every time timer ticks bar goes up by a random # between 1-10
        barLoad = barLoad + rndAdd.Next(11)
        prbLoading.Value = barLoad
        prbLoading.Refresh()


What I want to happen is for the progress bar to go up by a random value generated by the random variable. When I start debugging in vb 2010 the program crashes because vb doesn't like the line:

Code:

        barLoad = barLoad + rndAdd.Next(11)
I don't really understand what is going on because I am a complete noob at this stuff and this is really frustrating to figure out even though I know there is a simple way to fix it (I hope). I'm sorry if my problem was not thoroughly explained, but any help is appreciated!

Thanks,
~ Noslent

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>