Solved

timer control!

Posted on 2001-06-05
8
187 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

820 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