Solved

timer control!

Posted on 2001-06-05
8
184 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:m_durnell
8 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6157234
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
0
 
LVL 4

Expert Comment

by:PBuck
ID: 6157371
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!
0
 
LVL 2

Accepted Solution

by:
Microsoft earned 100 total points
ID: 6157544
have a look at this

http://www.freevbcode.com/ShowCode.Asp?ID=810

this does what you want it to

many thanks
Andy
0
 
LVL 1

Expert Comment

by:viperlin
ID: 6157730
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.


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6158494
listening...
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6158536
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 : )
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6162265
But I hope in glass cookie's one, there is no random display of quotes.

Cheers
0
 
LVL 1

Author Comment

by:m_durnell
ID: 6502420
Great , thanks very much for the link.

Cheers

Mark
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now