Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2004, 08:45 AM
Registered User
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can a non-visable control such as a timer be insta

Can a non-visible control such as a timer, or (wrapped) winsock, or (wrapped) MSComm be instanciated from within a module rather than on a form, the normal or default case? If so, how is it done, and how do I deal with the timer event when it is fired?? Is it something as simple as..

dim MyTimer as new ???
MyTimer.interval = 100
Mytimer.enable = true

( and then somewhere deal with the timer event?))
sub MyTimer.timer
''do something here

end sub



 
Old July 26th, 2004, 05:17 AM
Registered User
 
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If all you need is a timer, then you could use:

1) ccrp high performance timer dll http://ccrp.mvps.org/index.html?controls/ccrptimer6.htm (their documentation is easy to follow)
2) API SetTimer. The following code can be placed in a module and will perform a callback on the DoEvent method of m_objEventClass object

Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

Private m_objEventClass As Object
Private m_lngTimerID As Long

Public Sub PostEvent(objEventClass As Object, lngTimerInterval as long)

    Debug.Print "Posting Event"
    Set m_objEventClass = objEventClass
    m_lngTimerID = SetTimer(0, 0, lngTimerInterval, AddressOf PostEventCallback)

End Sub

Private Sub PostEventCallback(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal SysTime As Long)

    Debug.Print "Doing Callback"
    KillTimer 0, m_lngTimerID
    m_objEventClass.DoEvent
    Set m_objEventClass = Nothing

End Sub

 
Old July 26th, 2004, 05:18 AM
Registered User
 
Join Date: Jul 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oops! Apologies, I thought I was replying to a question on the ProVB forum. My bad.
a:






Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer control dipanjan22 ASP.NET 1.x and 2.0 Application Design 2 July 25th, 2007 12:00 PM
I need Coding for Timer Control Dhanapal ADO.NET 2 April 2nd, 2007 04:47 AM
Timer Control joebob_houston Access VBA 3 March 12th, 2007 08:31 AM
Timer Control sankar_massoft General .NET 0 December 21st, 2004 11:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.