Solved

timer control!

Posted on 2001-06-05
8
186 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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
 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 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