Professional conditions with IF
-
jhwurmbach wrote:
It sets the TextBox1.text to be "1"
Nope. Since it follows the
IF
statement, VB evaluatesTextBox1.Text=1
as a conditional expression (I don't know if it results in a run-time error).jhwurmbach wrote:
and then branches into the THEN, because 2 is equal to TRUE?
Yes. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]CPallini wrote:
(I don't know if it results in a run-time error)
It shouldn't; nearly all flavors of VB automatically coerce numerics into strings.
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means? :sigh:
-
CPallini wrote:
(I don't know if it results in a run-time error)
It shouldn't; nearly all flavors of VB automatically coerce numerics into strings.
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means? :sigh:
Robert Royall wrote:
It shouldn't; nearly all flavors of VB automatically coerce numerics into strings.
I was quite confident about too, but my
VBA
actually doesn't like the mix. Unfortunately I have no VB6 at hand. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Robert Royall wrote:
It shouldn't; nearly all flavors of VB automatically coerce numerics into strings.
I was quite confident about too, but my
VBA
actually doesn't like the mix. Unfortunately I have no VB6 at hand. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]Really? Works fine for me in Access 2003. It will throw an error if Textbox1 is empty, since you can't coerce a comparison with an empty string (or a null).
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means? :sigh:
-
Robert Royall wrote:
It shouldn't; nearly all flavors of VB automatically coerce numerics into strings.
I was quite confident about too, but my
VBA
actually doesn't like the mix. Unfortunately I have no VB6 at hand. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]CPallini wrote:
Unfortunately I have no VB6 at hand
Unfortunately X|
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Did you sack her for?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]No, we deported her and her friend cause they didn't skilled and they did lots of such mistakes ( I remember their nightmare creatures ). For example she named a function to something like this "girgo". X| Because of this naming, my friends named her "girgo". :laugh: Now the corporation focused on C#
-
Really? Works fine for me in Access 2003. It will throw an error if Textbox1 is empty, since you can't coerce a comparison with an empty string (or a null).
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means? :sigh:
Robert Royall wrote:
Really?
Yes.
Robert Royall wrote:
Works fine for me in Access 2003.
I'm using Excel 2002. But I think that VBA version difference doesn't really matter in this case.
Robert Royall wrote:
It will throw an error if Textbox1 is empty, since you can't coerce a comparison with an empty string (or a null).
IMHO it will NOT throw only if the
Textbox1.Text
value can be coerced to a number (i.e.Runtime Error
ifTextbox1.Text
is equal to "foo"). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
CPallini wrote:
Unfortunately I have no VB6 at hand
Unfortunately X|
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
In fact I like a lot of weird things... ;)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Robert Royall wrote:
Really?
Yes.
Robert Royall wrote:
Works fine for me in Access 2003.
I'm using Excel 2002. But I think that VBA version difference doesn't really matter in this case.
Robert Royall wrote:
It will throw an error if Textbox1 is empty, since you can't coerce a comparison with an empty string (or a null).
IMHO it will NOT throw only if the
Textbox1.Text
value can be coerced to a number (i.e.Runtime Error
ifTextbox1.Text
is equal to "foo"). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]CPallini wrote:
Runtime Error if Textbox1.Text is equal to "foo"
But... why on earth would that throw a Runtime Error? F00 is 3840... :wtf:
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means? :sigh:
-
CPallini wrote:
Runtime Error if Textbox1.Text is equal to "foo"
But... why on earth would that throw a Runtime Error? F00 is 3840... :wtf:
Please don't bother me... I'm hacking right now. Don't look at me like that - doesn't anybody remember what "hacking" really means? :sigh:
Because VB isn't such smart on number representations :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Robert Royall wrote:
It shouldn't; nearly all flavors of VB automatically coerce numerics into strings.
I was quite confident about too, but my
VBA
actually doesn't like the mix. Unfortunately I have no VB6 at hand. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
Nope. http://www.codeproject.com/script/Forums/View.aspx?fid=392254&msg=2393634[^] :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
One of our former staff wrote this professional IF clause in VB.NET(Hell language)
IF TextBox1.Text=1 or 2 or 3 THEN ' Go to hell END IF
:wtf: I tried to write codes like this, but couldn't. Can you help to write? :omg:SalarSoft wrote:
That is why it is Very Bad.
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson -
It's not uncommon at all to see coders express their frustrations in the code they write. For an entertaining afternoon of reading, go to http://www.google.com/codesearch[^] and enter the profanity of your choice. You'd be amazed what people say.
:laugh: :laugh: :laugh: :laugh: :laugh: Thanks for the link, I needed a good laugh. ;)
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
It's not uncommon at all to see coders express their frustrations in the code they write. For an entertaining afternoon of reading, go to http://www.google.com/codesearch[^] and enter the profanity of your choice. You'd be amazed what people say.
JohnnyLocust wrote:
Very interesting. Put in my name and found an old Java program I wrote back in college.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
-
Nope. http://www.codeproject.com/script/Forums/View.aspx?fid=392254&msg=2393634[^] :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]This kind of thing is standard shortcut syntax in COBOL (or was when I last used COBOL many years ago): IF X = 1 OR 2 THEN... is the same as IF X = 1 OR X = 2 THEN... The big gotcha comes when you add a NOT into the mix. All new COBOL programmers would at some point write a statement like: IF X NOT = 1 OR 2 THEN.. which unfortunately expands to IF X NOT = 1 OR X NOT = 2 THEN.. so the condition is always satisfied. Some of those beginners learn from the experience and don't make the mistake again. Others, however....
-
This kind of thing is standard shortcut syntax in COBOL (or was when I last used COBOL many years ago): IF X = 1 OR 2 THEN... is the same as IF X = 1 OR X = 2 THEN... The big gotcha comes when you add a NOT into the mix. All new COBOL programmers would at some point write a statement like: IF X NOT = 1 OR 2 THEN.. which unfortunately expands to IF X NOT = 1 OR X NOT = 2 THEN.. so the condition is always satisfied. Some of those beginners learn from the experience and don't make the mistake again. Others, however....
Member 2560472 wrote:
Some of those beginners learn from the experience
...and quicky abandon
COBOL
. :laugh:If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
It's not uncommon at all to see coders express their frustrations in the code they write. For an entertaining afternoon of reading, go to http://www.google.com/codesearch[^] and enter the profanity of your choice. You'd be amazed what people say.
Silence is the voice of complicity. Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay