473,761 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Absolute Beginner and Timer Class

Hi Im an absolute beginner in programming and am using VB.Net Express.

To start my larning I decided to do a "Real World" app instead of
"hello world" and am creating a Poker Countdown clock.

I pretty much have most things under control and have set it up as
follows:

Form 1 Contains a DataGridView where users enter in information
includeing the length of each round, small blind & big blind (its for
Texas Holdem Poker).

This then feeds the round information to Form2 which essential is the
display screen and includes the count down clock.

I can get it to read and run down the clock for the first round, but
am stumped on how I can get it to reset and pick up the infor for the
2nd and subsequant rounds.

I tried putting references back to the Timer1_Tick routine, but I get
an error message that says " argument not specified for parameter 'e'
of Public Sub Timer1_Tick(sen der as object, e as System.EventArg s).

I have listed the code (for form2) below and would appreciate any
feedback you can give me.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Class Form2
'Dim RoundLength As Integer = Form1.RoundLeng th
Dim RL As Integer = Form1.Round_Inf ormationDataGri dView.Item(1,
0).Value
Dim RoundLength As Integer = RL * 600
Dim RoundNumber As Integer = Form1.RoundNumb er
Dim SmallBlind As Integer =
Form1.Round_Inf ormationDataGri dView.Item(2, 0).Value
Dim BigBlind As Integer =
Form1.Round_Inf ormationDataGri dView.Item(3, 0).Value
Dim NextSmall As Integer =
Form1.Round_Inf ormationDataGri dView.Item(2, 1).Value
Dim NextBig As Integer =
Form1.Round_Inf ormationDataGri dView.Item(3, 1).Value

Private Sub Form2_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
Timer1.Enabled = False
Button1.Text = "Start"
Button2.Text = "Pause"
Label1.Text = "0" & RL & ":00"
Label2.Text = "Round " & RoundNumber
Label3.Text = SmallBlind
Label4.Text = BigBlind
Label5.Text = "Next Small Blind " & NextSmall
Label6.Text = "Next Big Blind " & NextBig
End Sub

Private CountDownStart

Private Sub button1_Click1( ByVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

If Not Timer1.Enabled Then

CountDownStart = Microsoft.Visua lBasic.DateAndT ime.Timer
Timer1.Enabled = True
Button1.Text = "Stop"
Button2.Text = "Pause"
Button2.Enabled = True
Else
Timer1.Enabled = False
'MsgBox("Final Time: " & Label1.Text & vbCrLf & vbCrLf &
"Click OK to reset the clock.")
Label1.Text = "0" & RL & ":00"
Button1.Text = "Start"
Button2.Text = "-----"
Button2.Enabled = False
End If

End Sub
Private Sub Button2_Click1( ByVal sender As Object, ByVal e As
System.EventArg s) Handles Button2.Click
Static PauseInterval
If Timer1.Enabled Then
PauseInterval = Microsoft.Visua lBasic.DateAndT ime.Timer -
CountDownStart
Timer1.Enabled = False
Button1.Text = "Restart"
Button2.Text = "Resume"
Else
CountDownStart = Microsoft.Visua lBasic.DateAndT ime.Timer -
PauseInterval
Timer1.Enabled = True
Button1.Text = "Stop"
Button2.Text = "Pause"
End If
End Sub

Public Sub Timer1_Tick(ByV al sender As Object, ByVal e As
System.EventArg s) Handles Timer1.Tick
Dim MinDiff
Dim SecDiff
Dim TenthDiff
Dim TimeDiff
'TimeDiff = (6000) -
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
TimeDiff = (RoundLength) -
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then
TenthDiff = TimeDiff Mod 10
SecDiff = Int(TimeDiff / 10) Mod 60
MinDiff = Int(TimeDiff / 600)
Label1.Text = Format(MinDiff, "00") & ":" &
Format(SecDiff, "00") '& "." & Format(TenthDif f, "0")

Else
Label1.Text = "00:00"
Timer1.Enabled = False
'MsgBox("!!!TIM E!!!")
RoundNumber += 1
Button1.Text = "Start"
Button2.Text = "-----"
Button2.Enabled = False
Timer1_Tick()

End If
Application.DoE vents()
End Sub

End Class

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Jun 18 '07 #1
4 2814
I cant follow where the problem is. What do you mean you cant get it to
"reset". My problem is I dont have form 1 and I cant see what you want to
acheive.

Seems to me the timer1 should fire at the interval you have specified and
then update the label1 with each tick.

You cant easily call a timer sub from vb.net as you have to pass the objects
and the e is a system object of the form System.EventArg s and has the event
info in it so you have to pass that).

Somtimes you can just put "nothing" or an empty object. But if that is what
you want to do then I would make a sub that goes in the timer event sub
called updatetick or something and then call that sub when I want, not the
timer.

Also, be sure to understand what Application.DoE vents does and I always
avoid having this in a timer loop cause you get funny behavior and you cant
step along with the debugger.

Hope this rambling helps point you to something to read about as I cant
understand the problem without spending more time or running in debug.
Someone else smarter prob will soon.

Tom
"Bails" wrote:
Hi Im an absolute beginner in programming and am using VB.Net Express.

To start my larning I decided to do a "Real World" app instead of
"hello world" and am creating a Poker Countdown clock.

I pretty much have most things under control and have set it up as
follows:

Form 1 Contains a DataGridView where users enter in information
includeing the length of each round, small blind & big blind (its for
Texas Holdem Poker).

This then feeds the round information to Form2 which essential is the
display screen and includes the count down clock.

I can get it to read and run down the clock for the first round, but
am stumped on how I can get it to reset and pick up the infor for the
2nd and subsequant rounds.

I tried putting references back to the Timer1_Tick routine, but I get
an error message that says " argument not specified for parameter 'e'
of Public Sub Timer1_Tick(sen der as object, e as System.EventArg s).

I have listed the code (for form2) below and would appreciate any
feedback you can give me.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Class Form2
'Dim RoundLength As Integer = Form1.RoundLeng th
Dim RL As Integer = Form1.Round_Inf ormationDataGri dView.Item(1,
0).Value
Dim RoundLength As Integer = RL * 600
Dim RoundNumber As Integer = Form1.RoundNumb er
Dim SmallBlind As Integer =
Form1.Round_Inf ormationDataGri dView.Item(2, 0).Value
Dim BigBlind As Integer =
Form1.Round_Inf ormationDataGri dView.Item(3, 0).Value
Dim NextSmall As Integer =
Form1.Round_Inf ormationDataGri dView.Item(2, 1).Value
Dim NextBig As Integer =
Form1.Round_Inf ormationDataGri dView.Item(3, 1).Value

Private Sub Form2_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
Timer1.Enabled = False
Button1.Text = "Start"
Button2.Text = "Pause"
Label1.Text = "0" & RL & ":00"
Label2.Text = "Round " & RoundNumber
Label3.Text = SmallBlind
Label4.Text = BigBlind
Label5.Text = "Next Small Blind " & NextSmall
Label6.Text = "Next Big Blind " & NextBig
End Sub

Private CountDownStart

Private Sub button1_Click1( ByVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

If Not Timer1.Enabled Then

CountDownStart = Microsoft.Visua lBasic.DateAndT ime.Timer
Timer1.Enabled = True
Button1.Text = "Stop"
Button2.Text = "Pause"
Button2.Enabled = True
Else
Timer1.Enabled = False
'MsgBox("Final Time: " & Label1.Text & vbCrLf & vbCrLf &
"Click OK to reset the clock.")
Label1.Text = "0" & RL & ":00"
Button1.Text = "Start"
Button2.Text = "-----"
Button2.Enabled = False
End If

End Sub
Private Sub Button2_Click1( ByVal sender As Object, ByVal e As
System.EventArg s) Handles Button2.Click
Static PauseInterval
If Timer1.Enabled Then
PauseInterval = Microsoft.Visua lBasic.DateAndT ime.Timer -
CountDownStart
Timer1.Enabled = False
Button1.Text = "Restart"
Button2.Text = "Resume"
Else
CountDownStart = Microsoft.Visua lBasic.DateAndT ime.Timer -
PauseInterval
Timer1.Enabled = True
Button1.Text = "Stop"
Button2.Text = "Pause"
End If
End Sub

Public Sub Timer1_Tick(ByV al sender As Object, ByVal e As
System.EventArg s) Handles Timer1.Tick
Dim MinDiff
Dim SecDiff
Dim TenthDiff
Dim TimeDiff
'TimeDiff = (6000) -
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
TimeDiff = (RoundLength) -
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then
TenthDiff = TimeDiff Mod 10
SecDiff = Int(TimeDiff / 10) Mod 60
MinDiff = Int(TimeDiff / 600)
Label1.Text = Format(MinDiff, "00") & ":" &
Format(SecDiff, "00") '& "." & Format(TenthDif f, "0")

Else
Label1.Text = "00:00"
Timer1.Enabled = False
'MsgBox("!!!TIM E!!!")
RoundNumber += 1
Button1.Text = "Start"
Button2.Text = "-----"
Button2.Enabled = False
Timer1_Tick()

End If
Application.DoE vents()
End Sub

End Class

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Jun 18 '07 #2
On Jun 19, 1:00 am, Tracks <Tra...@discuss ions.microsoft. comwrote:
I cant follow where the problem is. What do you mean you cant get it to
"reset". My problem is I dont have form 1 and I cant see what you want to
acheive.

Seems to me the timer1 should fire at the interval you have specified and
then update the label1 with each tick.

You cant easily call a timer sub from vb.net as you have to pass the objects
and the e is a system object of the form System.EventArg s and has the event
info in it so you have to pass that).

Somtimes you can just put "nothing" or an empty object. But if that is what
you want to do then I would make a sub that goes in the timer event sub
called updatetick or something and then call that sub when I want, not the
timer.

Also, be sure to understand what Application.DoE vents does and I always
avoid having this in a timer loop cause you get funny behavior and you cant
step along with the debugger.

Hope this rambling helps point you to something to read about as I cant
understand the problem without spending more time or running in debug.
Someone else smarter prob will soon.

Tom

"Bails" wrote:
Hi Im an absolute beginner in programming and am using VB.Net Express.
To start my larning I decided to do a "Real World" app instead of
"hello world" and am creating a Poker Countdown clock.
I pretty much have most things under control and have set it up as
follows:
Form 1 Contains a DataGridView where users enter in information
includeing the length of each round, small blind & big blind (its for
Texas Holdem Poker).
This then feeds the round information to Form2 which essential is the
display screen and includes the count down clock.
I can get it to read and run down the clock for the first round, but
am stumped on how I can get it to reset and pick up the infor for the
2nd and subsequant rounds.
I tried putting references back to the Timer1_Tick routine, but I get
an error message that says " argument not specified for parameter 'e'
of Public Sub Timer1_Tick(sen der as object, e as System.EventArg s).
I have listed the code (for form2) below and would appreciate any
feedback you can give me.
---------------------------------------------------------------------------*---------------------------------------------------------------------------*--------------
Public Class Form2
'Dim RoundLength As Integer = Form1.RoundLeng th
Dim RL As Integer = Form1.Round_Inf ormationDataGri dView.Item(1,
0).Value
Dim RoundLength As Integer = RL * 600
Dim RoundNumber As Integer = Form1.RoundNumb er
Dim SmallBlind As Integer =
Form1.Round_Inf ormationDataGri dView.Item(2, 0).Value
Dim BigBlind As Integer =
Form1.Round_Inf ormationDataGri dView.Item(3, 0).Value
Dim NextSmall As Integer =
Form1.Round_Inf ormationDataGri dView.Item(2, 1).Value
Dim NextBig As Integer =
Form1.Round_Inf ormationDataGri dView.Item(3, 1).Value
Private Sub Form2_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
Timer1.Enabled = False
Button1.Text = "Start"
Button2.Text = "Pause"
Label1.Text = "0" & RL & ":00"
Label2.Text = "Round " & RoundNumber
Label3.Text = SmallBlind
Label4.Text = BigBlind
Label5.Text = "Next Small Blind " & NextSmall
Label6.Text = "Next Big Blind " & NextBig
End Sub
Private CountDownStart
Private Sub button1_Click1( ByVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click
If Not Timer1.Enabled Then
CountDownStart = Microsoft.Visua lBasic.DateAndT ime.Timer
Timer1.Enabled = True
Button1.Text = "Stop"
Button2.Text = "Pause"
Button2.Enabled = True
Else
Timer1.Enabled = False
'MsgBox("Final Time: " & Label1.Text & vbCrLf & vbCrLf &
"Click OK to reset the clock.")
Label1.Text = "0" & RL & ":00"
Button1.Text = "Start"
Button2.Text = "-----"
Button2.Enabled = False
End If
End Sub
Private Sub Button2_Click1( ByVal sender As Object, ByVal e As
System.EventArg s) Handles Button2.Click
Static PauseInterval
If Timer1.Enabled Then
PauseInterval = Microsoft.Visua lBasic.DateAndT ime.Timer -
CountDownStart
Timer1.Enabled = False
Button1.Text = "Restart"
Button2.Text = "Resume"
Else
CountDownStart = Microsoft.Visua lBasic.DateAndT ime.Timer -
PauseInterval
Timer1.Enabled = True
Button1.Text = "Stop"
Button2.Text = "Pause"
End If
End Sub
Public Sub Timer1_Tick(ByV al sender As Object, ByVal e As
System.EventArg s) Handles Timer1.Tick
Dim MinDiff
Dim SecDiff
Dim TenthDiff
Dim TimeDiff
'TimeDiff = (6000) -
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
TimeDiff = (RoundLength) -
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then
TenthDiff = TimeDiff Mod 10
SecDiff = Int(TimeDiff / 10) Mod 60
MinDiff = Int(TimeDiff / 600)
Label1.Text = Format(MinDiff, "00") & ":" &
Format(SecDiff, "00") '& "." & Format(TenthDif f, "0")
Else
Label1.Text = "00:00"
Timer1.Enabled = False
'MsgBox("!!!TIM E!!!")
RoundNumber += 1
Button1.Text = "Start"
Button2.Text = "-----"
Button2.Enabled = False
Timer1_Tick()
End If
Application.DoE vents()
End Sub
End Class
---------------------------------------------------------------------------*---------------------------------------------------------------------------*--------- Hide quoted text -

- Show quoted text -
Thanks for your fast reply Tom.

Essentially on Form1 I have a datagridview. This has the information
on the various round levels for a Poker Tournament ie

Round Length of Round Small Blind Big Blind
1 10 (minutes) $25 $50
2 8 (minutes) $50 $100

So, I need the display screen (form2) to loop arround the number of
rounds (in this exanple its 2 rounds, however in reality can be any
number say 30 rounds).
So it would start at Round 1 and display the blinds ($25 and $50) once
it had counted down the 10 minutes, it moves down to the next round
(round 2) and starts the timer at 8 minutes and displays the blinds
for Round 2 ($50 and $100) all the way until there are no more
levels(rounds) left.

With the code I posted above I can get it to pickup and display
everything for the first round, then pick up all the info for the next
round, but cant seem to get the timer1_tick routine to start again.

I think you are correct when you say I need to pass it something, the
trouble is I have no idea WHAT to pass it or even HOW to pass it.

I have uploaded the entire project to : www.mediamax.com/ebaypoker if
you want to download it and have a look.

Once again - Thank you for your help.

Jun 19 '07 #3
Welp, you have:
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then

I am not seeing how this gets to be zero so the else case where the timer 1
is dis-enabled (and then resets) is never hit? But I gues it does?

And then yes, calling the Timer1_Tick() statement will give you an error
cause your not passing the parameters: ByVal sender As Object, ByVal e As
System.EventArg s. You could maybe do: Call Timer1_Tick(me, nothing) since you
dont use the paramenters.

Tom

Jun 19 '07 #4
On Jun 19, 11:26 pm, Tracks <Tra...@discuss ions.microsoft. comwrote:
Welp, you have:
Int((Microsoft. VisualBasic.Dat eAndTime.Timer - CountDownStart) * 10)
If TimeDiff >= 0 Then

I am not seeing how this gets to be zero so the else case where the timer 1
is dis-enabled (and then resets) is never hit? But I gues it does?

And then yes, calling the Timer1_Tick() statement will give you an error
cause your not passing the parameters: ByVal sender As Object, ByVal e As
System.EventArg s. You could maybe do: Call Timer1_Tick(me, nothing) since you
dont use the paramenters.

Tom
Tom - YOU ARE A GENIUS.

It works Perfectly.

THANKS SO MUCH for your help.

Do you play Poker Yourself - im happy to send you a copy once I get it
running the way I want it too.

Then again, you could probably build one any way.

Either way, let me know and I'll shoot it out to you if you want.

Thanks again

Bails

Jun 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7593
by: Shamrokk | last post by:
My application has a loop that needs to run every 2 seconds or so. To acomplish this I used... "Thread.Sleep(2000);" When I run the program it runs fine. Once I press the button that starts the looping function the window becomes unmovable and cannot close under its own direction (the upper right "close 'X'") My first attempt to solve the problem was to have the looping function execute as its own thread, the idea being this would...
3
2646
by: Neal | last post by:
managed C++ VS 2003 I have a beginner question about windows forms.... I need to call a function when a certain limit has been reached, now with the way VS sets up the .NET windows Form I get confused. When I was using Directx everything was being run from a while loop, so that was no problem for me in seeing where to place conditional statements and other functions. With windows forms do I need to have an event and eventhandler? it...
26
2393
by: Clodoaldo Pinto | last post by:
I'm starting a programming tutorial for absolute beginners using Python and I would like your opinions. http://programming-crash-course.com Regards, Clodoaldo Pinto
4
1695
by: Daniel | last post by:
Hey guys Here is what i want to do. I have made a multiplayer game that needs to when more than one player is ready start a countdown that the clients can see, so players can still join in this time frame and then after the time elapses the game starts. I am trying to do it lie this, my server controls all handling of the game logic, deciding who wins, who is next to play etc. For all the players to have their timers showing the same...
5
4916
by: muzilli | last post by:
Howdy all, I would like to know how can I insert a Timer object in my class library? This timer object will start and stop in a determinated part or event of my program. I know how to do this in Delphi or using a RAD tool and insert the Timer object in a form, but how to do in C# by hand and in a class library (without form), I don't know.
3
2231
by: horusprim | last post by:
Is there a CSS absolute positioning rendering bug in FF1.02 and IE 6? I have been experimenting with precision absolute positioning in CSS. The following test content was used in the experiment: "This sentence is to be about nine words long. I hope this test suite works. Mary had a little lamb and its fleece was white as snow." Next a macro was used to divide the content into equal sentence fragment spans of the 12 characters each...
12
5534
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different directories and updating a database. No interaction with the GUI. Problem is that the system timers do not have a tag property so I can tie in an object. example (old way):
5
12247
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the event handlers may take longer than the interval for either of the timers, so it's possible for multiple events to fire "simultaneously" and for events to queue up. I'm attempting to get the timers to sync on some reference type object, or use...
20
2297
by: weight gain 2000 | last post by:
Hello all! I'm looking for a very good book for an absolute beginner on VB.net or VB 2005 with emphasis on databases. What would you reccommend? Thanks!
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.