2 Replies - 1825 Views - Last Post: 14 February 2009 - 01:30 PM Rate Topic: -----

#1 Matt_Hacks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-February 09

Problem with Timer - VB.NET

Posted 13 February 2009 - 03:22 PM

I am making this application where you type and it times you to see how many words you type in 30 seconds....
the only problem is I can't get the timer to work properly :(

I want to have a label with a random sentence and a textbox for me to type the sentence into. i want the timer to start when i click on the textbox and start typing. And the timer i want to be at 30 seconds, and when it gets to 0 seconds the textbox should be readonly and then it tells you how many words are in the textbox.

Could you please help me? :)
##I AM NOT ASKING FOR CODE I AM NEEDING HELP AND WONDERING IF ANYONE COULD HELP ME OUT##
********THIS ISN'T FOR SCHOOL OR ANYTHING, IT IS FOR MY OWN PERSONAL USE********

I am trying to make my own version of MicroPace.
I am a noob at programming...PLEASE HELP ME!!! :)

This is my code for the application so far (without the timer code, cause thats what i need some help with)

Public Class Form1

	Private Sub tb1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb1.KeyDown
		If e.KeyCode = Keys.Back Then
			e.SuppressKeyPress = True
		End If
	End Sub

	Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb1.TextChanged
		If tb1.Text = lb1.Text Then
			MsgBox("Good Job...No Errors!!!", MsgBoxStyle.Exclamation, "Good Job!!")
		End If
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		lb1.Text = Int(Rnd() * 16)
		Select Case lb1.Text
			Case 0
				lb1.Text = "random sentence"
			Case 1
				lb1.Text = "jsabdkvjsv"
			Case 2
				lb1.Text = "asdfadsfifdnvk"
			Case 3
				lb1.Text = "sdfnjaskdkjvajnfvjka"
			Case 4
				lb1.Text = "sdjfnkjsadnvkajfv"
			Case 5
				lb1.Text = "sdjfbajisdvbkasbvjka"
			Case 6
				lb1.Text = "ajdvkadfnvjkdfv"
			Case 7
				lb1.Text = "sjnvjaksdfvlnadjv"
			Case 8
				lb1.Text = "jnvsdfvsdjfkvkas"
			Case 9
				lb1.Text = "msdfasdvadvjfs"
			Case 10
				lb1.Text = "Tasdnvjhakfvkfvn."
			Case 11
				lb1.Text = "sdkjadfsvbhkaljsdifva"
			Case 12
				lb1.Text = "sdvjabdjkvbabfvafdv"
			Case 13
				lb1.Text = "asdvbuasdnvuiabjsvdoiaskj"
			Case 14
				lb1.Text = "Aadsnvaisklvanadadvasdv"
			Case 15
				lb1.Text = "asjdbhvjasdfoijvbafsdv"
		End Select
		tb1.Text = ""
	End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Problem with Timer - VB.NET

#2 Ändrew  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 312
  • Joined: 21-April 08

Re: Problem with Timer - VB.NET

Posted 14 February 2009 - 12:03 AM

Fastest way i know is this


Dim counter As Integer
counter = [ENTER NUMBER]

Private function timer1 ect...

counter = counter - 1

End sub


Was This Post Helpful? 0
  • +
  • -

#3 Matt_Hacks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-February 09

Re: Problem with Timer - VB.NET

Posted 14 February 2009 - 01:30 PM

OK i got the timer to work but now i am trying to get it so when the timer runs out it will say how many words and errors are in the textbox!!!
this is the code for the application so far.... I just have no clue how to make it check for errors and show how many words are in the textbox...PLEASE HELP!!!


Public Class Form1
	Private alarmTime As Date
	Private Sub tb1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb1.Click
		Me.alarmTime = Date.Now.AddMinutes(1)
		Me.Timer1.Start()
	End Sub
	Private Sub tb1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tb1.KeyDown
		If e.KeyCode = Keys.Back Then
			e.SuppressKeyPress = True
		End If
	End Sub
	Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb1.TextChanged
		If tb1.Text = lb1.Text Then
			MsgBox("Good Job...No Errors!!!", MsgBoxStyle.Exclamation, "Good Job!!")
		End If
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		lb1.Text = Int(Rnd() * 16)
		Select Case lb1.Text
			Case 0
				lb1.Text = "adisvansidhvinasduvandivuadv"
			Case 1
				lb1.Text = "savbiuavuabdsvuiabbdviad"
			Case 2
				lb1.Text = "adsvuhiandsuabdvuaweadv."
			Case 3
				lb1.Text = "asdbviasdviuabsdvohasdhova"
			Case 4
				lb1.Text = "asdivnabshvaiushvnabsuivdasdbva"
			Case 5
				lb1.Text = "abhyugviuabdjhuvgiudsbsv"
			Case 6
				lb1.Text = "asjbivhaodnvbaeiurvb"
			Case 7
				lb1.Text = "jvasdioj9qw0erjvniy."
			Case 8
				lb1.Text = "asdjvasiojdvnajojjwer."
			Case 9
				lb1.Text = "asdjvbasivuonasdviudofn."
			Case 10
				lb1.Text = "Tnaisdhnvjaklmsdvjiaskdvja"
			Case 11
				lb1.Text = "Aadsivbanishvunasdvsadvas"
			Case 12
				lb1.Text = "sdjvbaidnvoidnvaohdifvafd."
			Case 13
				lb1.Text = "asdbfaisudjvbaiudsfvhiufv"
			Case 14
				lb1.Text = "asdvjasdvnafsvkadfv"
			Case 15
				lb1.Text = "anikjsdfvjadfvnaikdfv"
		End Select
		tb1.Text = ""
		Timer1.Stop()
	End Sub

	Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
		If CheckBox1.Checked = True Then
			Process.Start("http://www.google.com")
		End If
	End Sub
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		If alarmTime < Date.Now Then
			Me.Timer1.Stop()
			MessageBox.Show("Time's up.")
		Else
			Dim remainingTime As TimeSpan = Me.alarmTime.Subtract(Date.Now)

			Me.lb2.Text = String.Format("{0}:{1:d2}:{2:d2}", _
										   remainingTime.Hours, _
										   remainingTime.Minutes, _
										   remainingTime.Seconds)
		End If
	End Sub
End Class

This post has been edited by Matt_Hacks: 14 February 2009 - 01:31 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1