Announcement

Collapse
No announcement yet.

Animated Scrolling Text

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Animated Scrolling Text



    Is there a way in Vba to created animated or automatic scrolling text? I want to have a form with animated text showing credits of a addin? Is it possible to do this?

  • #2
    Re: Animated Scrolling Text

    Have you seen this previous post?
    http://www.ozgrid.com/forum/showthre...ight=scrolling

    Cheers
    Andy

    Comment


    • #3
      Re: Animated Scrolling Text

      Hey Andy, thanks alot. I searched but couldn't find a previous post. Thanks though for the link. I will look through it.

      Comment


      • #4
        Re: Animated Scrolling Text

        Ok, i've looked through and i don't understand whats going on? How do I use the excel files in powerpoint? I don't know about API's.
        Last edited by bwells; August 10th, 2006, 00:24.

        Comment


        • #5
          Re: Animated Scrolling Text

          Try this *NEW* method.

          It uses a listbox instead of a textbox and simple scrolls the information, by removing lines, like at the end of a movie.

          Option Explicit

          Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
          Private m_blnUnload As Boolean
          Private m_blnCreditsRolling As Boolean
          Private Sub CommandButton1_Click()

          If m_blnCreditsRolling Then
          m_blnUnload = True
          Else
          Unload Me
          End If

          End Sub
          Private Sub UserForm_Activate()

          Dim lngSpeed As Long

          m_blnCreditsRolling = True
          lngSpeed = 150
          Do While ListBox1.ListCount > 0
          ListBox1.RemoveItem 0
          DoEvents
          If m_blnUnload Then Exit Do
          Sleep lngSpeed
          Loop
          m_blnCreditsRolling = False
          If m_blnUnload Then CommandButton1_Click

          End Sub
          Private Sub UserForm_Initialize()

          Dim lngIndex As Long

          For lngIndex = 1 To 30
          ListBox1.AddItem "Line of credit " & lngIndex
          Next

          For lngIndex = 1 To 30
          ListBox1.AddItem ""
          Next

          End Sub

          The API is just a system function to delay the loop. Used to get finer control over the amount of time paused. The value is in milliseconds.
          Attached Files

          Cheers
          Andy

          Comment


          • #6
            Re: Animated Scrolling Text

            Alright, Thanks. Got a couple questions though

            1) Is there a special way to make the text scroll through multiple times? Or is it just a sample for loop around the whlie loop in the activate sub?

            2) I tried to modify this to pull string values from an array (each loop pulling one element from the array ) to show, but I alway get an error message on the start up of the form. Could using an array cause this problem?

            For example changing

            Code:
            Private Sub UserForm_Initialize() 
                 
                Dim lngIndex As Long 
                 
                For lngIndex = 1 To 30 
                    ListBox1.AddItem "Line of credit " & lngIndex 
                Next 
                 
                For lngIndex = 1 To 30 
                    ListBox1.AddItem "" 
                Next 
                 
            End Sub
            To

            Code:
            Private Sub UserForm_Initialize()
            
                Dim lngIndex As Long
                Dim credit As Variant
                
                credit = Array("test", "test 1", "test 2")
                
                For lngIndex = 1 To len(credit)
                    ListBox1.AddItem credit(lngIndex)
                Next
                
                For lngIndex = 1 To (credit)
                    ListBox1.AddItem ""
                Next
                
            End Sub
            That is what I had to cause the error. Any idea what i'm doing wrong?

            Comment


            • #7


              Re: Animated Scrolling Text

              You need to add another loop for multiple rolls of the same credits.

              And use LBound and UBound to get arrays size
              Code:
              Private Sub UserForm_Activate()
              
                  Dim lngSpeed As Long
                  Dim lngRepeat As Long
                  Dim lngCredit As Long
                  
                  m_blnCreditsRolling = True
                  lngSpeed = 150
                  
                  For lngRepeat = 1 To 3
                      For lngCredit = 0 To ListBox1.ListCount - 1
                          ListBox1.AddItem ListBox1.List(0)
                          ListBox1.RemoveItem 0
                          DoEvents
                          If m_blnUnload Then Exit For
                          Sleep lngSpeed
                      Next
                  Next
                  m_blnCreditsRolling = False
                  If m_blnUnload Then CommandButton1_Click
                  
              End Sub
              
              Private Sub UserForm_Initialize()
              
                  Dim lngIndex As Long
                  Dim credit As Variant
                   
                  credit = Array("test", "test 1", "test 2")
                   
                  For lngIndex = LBound(credit) To UBound(credit)
                      ListBox1.AddItem credit(lngIndex)
                  Next
                   
                  For lngIndex = LBound(credit) To UBound(credit)
                      ListBox1.AddItem ""
                  Next
                  
              End Sub
              This revision simply moves the top row of the list box to the bottom.
              Last edited by S M C; October 30th, 2010, 20:10. Reason: [vba][/vba] Code Tags To [Code][/Code] (Dave, any automated way to correct this?)

              Cheers
              Andy

              Comment

              Working...
              X