I am trying to make sure a string reads am or pm before I let the variable be passed to a check routine. I used this but its not working right.
Code:If alrmampm <> "AM" Or alrmampm <> "PM" Then MsgBox("Enter a valid time.") ampmcb.SelectAll() Exit Sub End If
But I used the same comparison format here, and it works fine.
I'm probably going about this the wrong way, but until I learn the vb syntax better I have to work with what I know. So could someone tell me why that expression isn't working?Code:If alrmhours = "" Or alrmhours < 0.ToString Or alrmhours > 12.ToString Then MsgBox("Enter a valid time.") hourscb.SelectAll() Exit Sub End If If alrmminutes = "" Or alrmminutes < 0.ToString Or alrmminutes > 59.ToString Then MsgBox("Enter a valid time.") minutescb.SelectAll() Exit Sub End If







Reply With Quote