Textbox and Timers

Using a textbox to change the timer interval.

Page 1 of 1

3 Replies - 1710 Views - Last Post: 25 August 2009 - 02:58 PM Rate Topic: -----

#1 Cele  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-August 09

Textbox and Timers

Posted 25 August 2009 - 02:06 PM

Basically I am trying to have it so when they click the save button it changes the timer.interval to what they entered in the textbox.

On form load I have it do this.

Timer2.Interval = My.Settings.timer_interval 
timertxt.Text = Timer2.Interval / 1000


When they click the save button.
My.Settings.timer_interval = timertxt.Text * 1000
Timer2.Interval = My.Settings.timer_interval


The program works, but it throws an error

Conversion from string "" to type 'Integer' is not valid.

I understand that the textbox is a string and the Timer Interval is a Integer, I am just curious if anyone can help me make it work without having to click continue after it throws the error.

Is This A Good Question/Topic? 0
  • +

Replies To: Textbox and Timers

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,054
  • Joined: 02-July 08

Re: Textbox and Timers

Posted 25 August 2009 - 02:31 PM

Use:
My.Settings.timer_interval = Convert.ToInt32(timertxt.Text) * 1000
Timer2.Interval = My.Settings.timer_interval

Was This Post Helpful? 1
  • +
  • -

#3 Ian2009  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 31
  • Joined: 07-April 09

Re: Textbox and Timers

Posted 25 August 2009 - 02:31 PM

have you set an initial value for My.Settings.timer_interval?

add this as 1st line into you form_load event handler to verify it's value. it's probably empty.

MsgBox(My.Settings.timer_interval)

This post has been edited by Ian2009: 25 August 2009 - 02:31 PM

Was This Post Helpful? 0
  • +
  • -

#4 Cele  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 25-August 09

Re: Textbox and Timers

Posted 25 August 2009 - 02:58 PM

@Hawk testing now, thanks.
@Ian I do have a default value, that wasn't the issue I was just having an issue with converting which I think Ian solved :). Thanks for the reply though.

EDIT:
@Hawk, worked, I just changed a few things around, I feel dumb for not doing that ohwell thanks alot man.

This post has been edited by Cele: 25 August 2009 - 03:01 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1