UnexpectedCastException was uhandled [solved]

Posts 1–15 of 15 · Page 1 of 1
UnexpectedCastException was uhandled [solved]
I am working on a simple spammer, but I keep getting this error when making the "Set Interval"

[highlight=vb.net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox5.Text = ("") Then
MsgBox("Please, put a valid number value", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "ERROR")
Else

End If
Timer1.Interval = TextBox1.Text * 1000

End Sub[/highlight]


The Timer1.Interval = ((TextBox1.Text) * (1000)) is giving the error.

isn't it just
Code:
timer1.interval = TextBox1.Text * 1000
Quote Originally Posted by hustelboy View Post
isn't it just
Code:
timer1.interval = TextBox1.Text * 1000
That's what i already have?
i tried the asme as you but for me its working....
Quote Originally Posted by hustelboy View Post
i tried the asme as you but for me its working....
It debugs fine. But when I put a number in the text box under interval, it closes the application and gives a error.
Quote Originally Posted by hustelboy View Post
nvm
Got teamview ???
Yes I do.

830 140 153

5164

I'll only accept you.




Quote Originally Posted by master131 View Post
You're implicity casting a String to an Integer.
Code:
Timer1.Interval = CInt(TextBox1.Text) * 1000
It would be better to use a NumericUpDown control otherwise if someone puts letters into text box the program will shit itself.
I just edited it and I still get the same error.
You're implicity casting a String to an Integer.
Code:
Timer1.Interval = CInt(TextBox1.Text) * 1000
It would be better to use a NumericUpDown control otherwise if someone puts letters into text box the program will shit itself.
Quote Originally Posted by master131 View Post
You're implicity casting a String to an Integer.
Code:
Timer1.Interval = CInt(TextBox1.Text) * 1000
It would be better to use a NumericUpDown control otherwise if someone puts letters into text box the program will shit itself.
@master131

I added a NumericUpDown control instead. What code do I need to put in?
Quote Originally Posted by SofaKingH4rd View Post
@master131

I added a NumericUpDown control instead. What code do I need to put in?
[highlight=vb.net]
Timer1.Interval = NumericUpDown.Value * 1000
[/highlight]
Quote Originally Posted by Jason View Post


[highlight=vb.net]
Timer1.Interval = NumericUpDown.Value * 1000
[/highlight]

Thank you, It works perfectly now. Can you tell I'm new to visual basic?
Quote Originally Posted by SofaKingH4rd View Post
Can you tell I'm new to visual basic?
yes....
/toshort
try...

[highlight=vb.net]
try
Timer1.Interval = CInt.parse(TextBox1.Text) * 1000
catch
msgbox("please enter numbers only")
end try
[/highlight]
Quote Originally Posted by *****179 View Post
try...

[highlight=vb.net]
try
Timer1.Interval = CInt.parse(TextBox1.Text) * 1000
catch
msgbox("please enter numbers only")
end try
[/highlight]
didn't work. Have you got team viewer??
Obviously. You should attempt to read the documentation (at least the properties) of any control you intend to use. MSDN is particularly helpful in this regard. It will make your life a lot easier once you start understand the capabilities of the controls you are using.

Marked Solved.
Posts 1–15 of 15 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us