-4

I am currently trying to use the value of a textbox as the value of an integer in a Timer so its like this

User inputs a value my application reads it and uses the input as a value of interval in a timer but its giving me this error, whats going on? Here is what it looks like

  • 1
    Have you had a look what `TextBox.Text`actually returns? It´s obviously not an integer, it´s a string, isn´t it? So you should convert the string to an int, google this and you´re done. – MakePeaceGreatAgain Jun 15 '16 at 14:31

3 Answers3

0

You Need to Convert into Integer from string.Then you can use it. exp:

 int timeInterval = Convert.ToInt32(txtTime.Text);

Use can use the Variable value(timeInterval).

Jagadisha B S
  • 673
  • 4
  • 11
  • 26
0

Thread.Sleep() takes an integer value, but you are passing the string value into the function. Any value taken from the user input like as Textbox.Text is treated as string and you need to convert that to an int.

vivek
  • 1,595
  • 2
  • 18
  • 35
0

You will have to convert your String to Int like so:

int timeInterval = Int32.Parse(txtTime.Text);
user3378165
  • 6,546
  • 17
  • 62
  • 101