Public Class Form1
Public int As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Randx As New Random
TextBox1.Text = Randx.Next(1, 2)
TextBox2.Text = Randx.Next(1, 2)
If TextBox1.Text = TextBox2.Text Then
Timer1.Stop()
My.Computer.Audio.Play(My.Resources.fart, AudioPlayMode.Background)
int = int + 1
Label1.Text = int
Timer1.Start()
End If
End Sub
Label only counts up to 9
Page 1 of 13 Replies - 602 Views - Last Post: 22 April 2011 - 09:30 AM
#1
Label only counts up to 9
Posted 21 April 2011 - 03:53 PM
am working on an app that generates 2 random numbers. When the numbers match it plays a sound. I'm trying to keep count of each time this accurs by using a label to hold the number each time it counts. It's working but when I use a label it only counts up to 9 then goes back to one and stays there. Here is a snippet of the code I wrote.
Replies To: Label only counts up to 9
#2
Re: Label only counts up to 9
Posted 21 April 2011 - 04:10 PM
I tested this with a textbox and thought it worked. I have 5 timers with similar code but each one plays a different sound. Seemed to work ok with one timer running the code into a text box. But when I turned them all on seems to give me random results for the count.
#3
Re: Label only counts up to 9
Posted 21 April 2011 - 07:12 PM
gec5741, on 21 April 2011 - 04:10 PM, said:
I tested this with a textbox and thought it worked. I have 5 timers with similar code but each one plays a different sound. Seemed to work ok with one timer running the code into a text box. But when I turned them all on seems to give me random results for the count.
Well I'm just slow I guess. And new. I figured itout. I had it right but I had to use a diff var per timer. Now all working like I planned. thanks.
#4
Re: Label only counts up to 9
Posted 22 April 2011 - 09:30 AM
gec5741, on 21 April 2011 - 07:12 PM, said:
gec5741, on 21 April 2011 - 04:10 PM, said:
I tested this with a textbox and thought it worked. I have 5 timers with similar code but each one plays a different sound. Seemed to work ok with one timer running the code into a text box. But when I turned them all on seems to give me random results for the count.
Well I'm just slow I guess. And new. I figured itout. I had it right but I had to use a diff var per timer. Now all working like I planned. thanks.
Was just about to comment sir, but I'm glad you figured it out anyhow.
By the way "+=" is a good habit to pick up on when you are incrementing. Spare ya some confusion in the future.
This post has been edited by trevster344: 22 April 2011 - 09:31 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|