|
-
Nov 28th, 2012, 01:04 AM
#1
Thread Starter
Addicted Member
-
Nov 28th, 2012, 01:35 AM
#2
Re: Can a timers 'interval' be Set via a Textbox value edited on a windows form?
Think about it. If you want to display some text in a TextBox or Label at run time, what do you do? You simply write some code to set the Text property, right? The Interval property of a Timer is just a property, the same a the Text of a TextBox or Label, so you set it the same way.
-
Nov 28th, 2012, 03:19 AM
#3
Thread Starter
Addicted Member
Re: Can a timers 'interval' be Set via a Textbox value edited on a windows form?
So then using button1_click.... Timer1.Interval = TextBox1.Text
The same way I would do button2_click .... TextBox1.Text = "yo momma"
I'm guessing? Difference is...I was thinking that the static interval set via the IDE would be somehow different. Thanks for making me feel dumb, you got the perfect recipe for that... for me lol
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Nov 28th, 2012, 10:04 AM
#4
Re: Can a timers 'interval' be Set via a Textbox value edited on a windows form?
Here is one way of doing this. Note that I check that what is in the textbox is numeric.
Code:
Private Sub TextBox1_TextChanged(sender As System.Object, _
e As System.EventArgs) Handles TextBox1.TextChanged
'used to set timer interval on the fly
'user input is number of ms followed immediately by #
'e.g. 1000# = 1000 ms
If TextBox1.Text.Trim.EndsWith("#") Then 'does textbox end with #
'yes
Dim s As String = TextBox1.Text.Trim.TrimEnd(New Char() {"#"c}) 'get number part
Dim i As Integer
If Integer.TryParse(s, i) Then 'if it is an integer set timer1.interval
Timer1.Interval = i
TextBox1.Text = ""
Else
Debug.WriteLine("error nan") 'not a number
End If
End If
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|