Alarm Timer code error

Posts 1–12 of 12 · Page 1 of 1
Try to use TimeOfDay as a string. I think I've had this problem before...
Conversion from string "Label2" to type 'Date' is not valid.

is because the data types are not the same. Ie. Label.Text (a string) must be set == a string

Dim xx as Int32 = "MyNameIsSteve" // invalid! a number can't be set to a string.
Dim ss as String = 123456 // invalid!

Dim xx as DateTime = 1234 // invalid.

Dim xx as Int32 = Date.Now() // invalid.


ie. as pepsihacker said 'Try to use TimeOfDay as a string.'

Label1.Text = Date.Now.ToString() // has LOTS of overloads.
(ToString is special, I'm not going to explain why)

Label1.Text = TimeOfDat <--String variable, Date variable--> NOT the same 'type'.
your smart at VB do you dose HTML?
Quote Originally Posted by abuckau907 View Post
Conversion from string "Label2" to type 'Date' is not valid.

is because the data types are not the same. Ie. Label.Text (a string) must be set == a string

Dim xx as Int32 = "MyNameIsSteve" // invalid! a number can't be set to a string.
Dim ss as String = 123456 // invalid!

Dim xx as DateTime = 1234 // invalid.

Dim xx as Int32 = Date.Now() // invalid.


ie. as pepsihacker said 'Try to use TimeOfDay as a string.'

Label1.Text = Date.Now.ToString() // has LOTS of overloads.
(ToString is special, I'm not going to explain why)

Label1.Text = TimeOfDat <--String variable, Date variable--> NOT the same 'type'.
label1.text = timeofday

if label2.text = label1.text then
label3.text = "Alarm!!"
timer1.stop
endif
Easy way.
Errrm, lol?
MsgBoxStyle is part of the actual message of the MSGBox. you might wanna change where the quotation marks are.
Solved
I dont know how to change it.
Here are several methods to fix your error (@abuckau907 these methods are "better" in my opinion.)

1.) Create a global variable for the date you are waiting for.
2.) Use
Code:
if wait_date <= date.now then
'code
else
'code
end if
OR you can also use
Code:
if Cdate(label2.text) <= date.now then
'code
else
'code
end if
This is assuming you are using date.now for the date, or are at least following correct date datatype formatting. (Example (Generated with date.now) 3/10/2013 4:33:55 PM)
(@rileyjstrickland "Better." Better than what? Did I post a solution to his problem, or a description (albeit poor) of the problem?
When OP knows what data type is, I might start talking about 'efficiency'/'better'.)
Quote Originally Posted by abuckau907 View Post
(@rileyjstrickland "Better." Better than what? Did I post a solution to his problem, or a description (albeit poor) of the problem?
When OP knows what data type is, I might start talking about 'efficiency'/'better'.)
It was late and I was tired. When I'm awake your posts are hard enough to read .
Please format them a little bit
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?