Link to home
Start Free TrialLog in
Avatar of m_durnell
m_durnellFlag for United Kingdom of Great Britain and Northern Ireland

asked on

timer control!

Hi

I would like to be able to display quotes on screen at different time intervals, in other words I would like to display a quote on the screen, and then say 30 seconds later display a different quote and so on.......I would also like to display these quotes in random order.

Any ideas would be appreciated.

Cheers

Mark
Avatar of HemanthaKumar
HemanthaKumar

Check this URL : http://www.planet-source-code.com/xq/ASP/txtCodeId.22701/lngWId.1/qx/vb/scripts/ShowCode.htm


I have modified a little bit to add timer functionality to it

1. In form load initialize the timer interval
2. In timer sub, call the quote display

This is an example and you can do more.
=============================

Dim s() As String, x As Integer


Private Sub cmdRandomBushim_Click()
txtbush = s(Random_Num(UBound(s)))
End Sub

Private Sub Form_Load()
Timer1.Interval = 10000
Open_Bushims
txtbush = s(Random_Num(UBound(s)))
End Sub

Public Sub Open_Bushims()
x = 0
Open App.Path & "\bush.txt" For Input As #1
Do While Not EOF(1)
   Input #1, tmps
   x = x + 1
   ReDim Preserve s(x)
   s(x) = tmps
Loop
Close

End Sub


Public Function Random_Num(ByVal max As Integer) As Integer
Randomize Timer
Random_Num = Int((max * Rnd) + 1)
End Function

Private Sub Label1_Click()
Shell "start http://slate.msn.com/Features/bushisms/bushisms.asp"
End Sub

Private Sub Label4_Click()
Shell "start http://go.to/wdwtbam"

End Sub

Private Sub Timer1_Timer()
Call cmdRandomBushim_Click
End Sub
===========================

~Hemanth
One simple way would be to set the Timer control to the lowest marked time (1 second).  Create a Long variable private to the form.

Private lCount as Long

Private Sub frmMain_Load()
  lCount = 0
  Timer1.Interval = 1000
End Sub

Private Sub Timer1_Interval()
  lCount = lCount + 1
  Select case lCount
    Case 30
      'Do your display
    Case 45
      'Do your display
    Case 120
      'Do your display
    Case 300
      'Reset the counter at any time
      lCount = 0
  End Select
End Sub

This is just another option.  Hope this helps!
ASKER CERTIFIED SOLUTION
Avatar of Microsoft
Microsoft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
put all the quotes in a text file.

on form load read the contents of the file into an array.

set the timer controls interval to 30000.

the code for the timer control is similar to this:

'
'
'
'
private sub myTimer_Timer()
   randomize timer

   ' this will generate a random index into the quotes array
   myVar = int(rnd(1)*ubound(MY_ARRAY) + 1

   ' this would display the quote in the debug window  
   debug.print MY_ARRAY(myVar)

end sub
'
'
'
'

the only downside to this is that you waste alot of memory holding the contents of all the quotes in memory.  if there are 50 thousand quotes a better scheme would be to read in random quotes in the form load event and just cycle through them with the timer control.


listening...
Avatar of glass_cookie
Hi!

How about trying this:

If Quote.Caption = "This is the day" Then
Quote.Caption = "Nice day!"
ElseIf Quote.Caption = "Nice day!" Then
Quote.Caption = "Happy day..."
'...
'...
End If

That's it!

glass cookie : )
But I hope in glass cookie's one, there is no random display of quotes.

Cheers
Avatar of m_durnell

ASKER

Great , thanks very much for the link.

Cheers

Mark