You must have misread me somehow, Mr Mills; I didn't say there's a '!' operator in VBA. You spoke of a '!' operator in C, but I've never heard of that operator in VBA; all I meant is that maybe I should look in VBA for another Boolean operator that is different from NOT as you say '!' is different from '~' in C.
--- Bob Bridges, robhbrid...@gmail.com, cell 336 382-7313 /* That sort of wit which employs itself insolently in criticizing and censuring the words and sentiments of others in conversation is absolute folly; for it answers none of the ends of conversation. He who uses it neither improves others, is improved himself, nor pleases anyone. -Poor Richard’s Almanack, 1756 */ -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Charles Mills Sent: Saturday, June 6, 2020 15:34 https://www.tutorialspoint.com/cprogramming/c_operators.htm for C operators I don't know VBA at all, only some VB. Are you sure about the ! operator being "complement"? https://bytecomb.com/the-bang-exclamation-operator-in-vba/ https://www.tutorialspoint.com/vba/vba_operators.htm -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Bob Bridges Sent: Saturday, June 6, 2020 10:57 AM Really, a different operator? I didn't know; I bought a C compiler once, a couple decades ago, but then never used it. Now I'm wondering whether VBA has such a distinction and I simply assumed, and never looked for it. I don't think so, but I should remember to look. -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Charles Mills Sent: Saturday, June 6, 2020 11:35 The problem would seem to me to stem from having the same operator for Boolean Not and for Bit Complement. Apparently VBA uses ! for both. I believe that in C or C++ if ( ! Result ) would evaluate as you expected: first Result would be evaluated as true or false, then that truth value would be logically inverted, and then that inversion evaluated as true or false. C has a separate operator for complement -- the tilde ~ -- and in C you would have to code if ( ~ Result ) to get the anomalous behavior you describe. -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Bob Bridges Sent: Friday, June 5, 2020 11:00 PM Reminds me of a situation I had some years ago while writing a VBA program that used a class (for FTP, I think) that had been written in some flavor of C. I was testing a supposedly Boolean return code and getting unexpected results. I tried several ways, and eventually proved to myself that the return code was both True and False. That is: Result = Function(Argument) If Result Then MsgBox "True" If Not Result Then MsgBox "False" ...displayed ~both~ messages. Maybe some of you already know what was happening here, but I had to examine the returned value in hex to catch on. VBA uses -1 (1111 1111b) for True and 0 (0000 0000b) for False, but evaluates 0 as False and any non-zero number as True. The Not operand uses two's complement to negate. But C, I gather, uses 0 for False and 1 for True. So in this case I was getting a 1 back from the function (0000 0001b), which VBA evaluated as True - and when I said "Not Result", it negated 1 into -2 (1111 1110b) and evaluated that as True also. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN