Solved

timer control!

Posted on 2001-06-05
8
183 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 9

Expert Comment

by:Valliappan AN
Comment Utility
listening...
0
 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
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
Comment Utility
But I hope in glass cookie's one, there is no random display of quotes.

Cheers
0
 
LVL 1

Author Comment

by:m_durnell
Comment Utility
Great , thanks very much for the link.

Cheers

Mark
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now