Results 1 to 8 of 8

Thread: Random scrolling test (Resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Lewiston, Maine
    Posts
    128

    Random scrolling test (Resolved)

    I have a text scroller which I wish to randomly change the text in. As you can see I have two text strings in two variables. I wish to randomly select one or the other and place in the Scroll1.Caption. I can't seem to figure out how to do this. Please help!


    VB Code:
    1. Dim scrolltext0 As String
    2. Dim scrolltext1 As String
    3.  
    4. scrolltext0 = "Down by the pond"
    5. scrolltext1 = "Over by the tree"
    6.  
    7. Scroll1.Caption = scrolltext
    8. Scroll1.Interval = 0.5
    Last edited by purdybirds; Aug 2nd, 2004 at 10:48 AM.

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    What's a "text scroller"? Is it an object?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Lewiston, Maine
    Posts
    128
    It's just a third party text scroller like a marque. The only thing to be concerned with is the .caption which is the text being scrolled.

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    VB Code:
    1. Dim scrolltext(1) As String
    2.    
    3.     Randomize Timer
    4.     scrolltext(0) = "Down by the pond"
    5.     scrolltext(1) = "Over by the tree"
    6.    
    7.     'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    8.     Scroll1.Caption = scrolltext(Int(2 * Rnd))
    9.     Scroll1.Interval = 0.5
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Lewiston, Maine
    Posts
    128
    I've tried the code. I've restarted the program 20 times and the same string "Down by the pond" scrolls by. Is this just by chance?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Lewiston, Maine
    Posts
    128
    I just saw what is wrong. Your code has randomize timer. I don't have a timer. I removed the timer and it works great now. Thank you very much.

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    My guess is that the code is not running. Where did you place this code? Is it in any event?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  8. #8
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    You don't need any timer for that code to work.

    Randomize Statement


    Initializes the random-number generator.

    Syntax

    Randomize [number]

    The optional numberargument is aVariant or any validnumeric expression.

    Remarks

    Randomize uses number to initialize the Rnd function's random-number generator, giving it a newseed value. If you omit number, the value returned by the system timer is used as the new seed value.

    If Randomize is not used, the Rnd function (with no arguments) uses the same number as a seed the first time it is called, and thereafter uses the last generated number as a seed value.

    Note To repeat sequences of random numbers, call Rnd with a negative argument immediately before using Randomize with a numeric argument. Using Randomize with the same value for number does not repeat the previous sequence.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

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