aaronk Well-Known Member Licensed User Longtime User Mar 3, 2013 #1 Hello, I can't seem to work this 'If statement' out.. what I have is: Code: Copy dim value as string = "4" If value => "1" & =< "10" Then Return "Number is between 1 and 10"" but I get the following error: Error description: Object reference not set to an instance of an object. Occurred on line: 305 If value => "1" & =< "10" Then Return "Number is between 1 and 10" Word: = Click to expand... Anyone got any ideas what I am doing wrong?
Hello, I can't seem to work this 'If statement' out.. what I have is: Code: Copy dim value as string = "4" If value => "1" & =< "10" Then Return "Number is between 1 and 10"" but I get the following error: Error description: Object reference not set to an instance of an object. Occurred on line: 305 If value => "1" & =< "10" Then Return "Number is between 1 and 10" Word: = Click to expand... Anyone got any ideas what I am doing wrong?
barx Well-Known Member Licensed User Longtime User Mar 3, 2013 #2 An '&' is for concatination. You need the logical AND Using your example would become Code: Copy If (value => "1") AND (value =< "10") Then Return Upvote 0
An '&' is for concatination. You need the logical AND Using your example would become Code: Copy If (value => "1") AND (value =< "10") Then Return
IanMc Well-Known Member Licensed User Longtime User Mar 3, 2013 #3 I think you have these wrong too: => =< They should be >= and <= then i was thinking? perhaps => and =< are functions for casting strings into numbers and then checking for greater than or less than so I did this: Code: Copy Dim value As String = "4" If value => "1" AND value =< "10" Then ToastMessageShow("Number is between 1 and 10", True) End If but I got a syntax error so I'm pretty sure that your test needs to be without quotes as well This works: Code: Copy Dim value As String = "4" If value >= 1 AND value <= 10 Then ToastMessageShow("Number is between 1 and 10", True) End If No, I was wrong, this also works: Code: Copy Dim value As String = "4" If value >= "1" AND value <= "10" Then ToastMessageShow("Number is between 1 and 10", True) End If so you can leave them in quotes if you want but you have to get the operators correct. Last edited: Mar 3, 2013 Upvote 0
I think you have these wrong too: => =< They should be >= and <= then i was thinking? perhaps => and =< are functions for casting strings into numbers and then checking for greater than or less than so I did this: Code: Copy Dim value As String = "4" If value => "1" AND value =< "10" Then ToastMessageShow("Number is between 1 and 10", True) End If but I got a syntax error so I'm pretty sure that your test needs to be without quotes as well This works: Code: Copy Dim value As String = "4" If value >= 1 AND value <= 10 Then ToastMessageShow("Number is between 1 and 10", True) End If No, I was wrong, this also works: Code: Copy Dim value As String = "4" If value >= "1" AND value <= "10" Then ToastMessageShow("Number is between 1 and 10", True) End If so you can leave them in quotes if you want but you have to get the operators correct.
aaronk Well-Known Member Licensed User Longtime User Mar 3, 2013 #4 Thanks for your reply's.. I ended up doing it like below and it worked: Code: Copy dim value as string = "4" If (value > "0") AND (value < "11") Then Return "between 1 and 10" Upvote 0
Thanks for your reply's.. I ended up doing it like below and it worked: Code: Copy dim value as string = "4" If (value > "0") AND (value < "11") Then Return "between 1 and 10"
IanMc Well-Known Member Licensed User Longtime User Mar 3, 2013 #5 Awww that's cheating :sign0098: Upvote 0
barx Well-Known Member Licensed User Longtime User Mar 3, 2013 #6 Good work IanMc, I do keep missing these little details. Mind it is usually early in a morning when I post. Good job others follow me up lol. Maybe I should stick to reading in the mornings and leave posting for evenings:sign0013: Upvote 0
Good work IanMc, I do keep missing these little details. Mind it is usually early in a morning when I post. Good job others follow me up lol. Maybe I should stick to reading in the mornings and leave posting for evenings:sign0013: