Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_IIF limits two questions
#8
(12-21-2024, 12:02 AM)Pete Wrote: Petr's example as a string I think would be...

Code: (Select All)
Dim result as String
a$ = "Yes"
result = _IIf(a$ = "YES", "a$ is YES", "a$ is not YES" )
Print result

I say think because I haven't downloaded and installed the new version yet.

Someone please correct Steve if I am wrong. Big Grin

Pete
I haven't used the new _IIF command yet, but in VBA  (and VB6 if I recall?) you could use IIF to return multiple types. 

In QB64 / QB64PE, I had to make seperate functions for different return types, like below, but it would be nice if the built-in _IIF command just worked with whatever type you passed in for parameters 2 & 3 (as long as parameters 2 & 3 aren't 2 different types)... 

Code: (Select All)
'Integer
Function IIF% (Condition, IfTrue%, IfFalse%)
    If Condition Then IIF% = IfTrue% Else IIF% = IfFalse%
End Function

'String
Function IIFS$ (Condition, IfTrue$, IfFalse$)
    If Condition Then IIFS$ = IfTrue$ Else IIFS$ = IfFalse$
End Function

'Long
Function IIFL& (Condition, IfTrue&, IfFalse&)
    If Condition Then IIFL& = IfTrue& Else IIFL& = IfFalse&
End Function

'Single
Function IIFSng! (Condition, IfTrue!, IfFalse!)
    If Condition Then IIFSng! = IfTrue! Else IIFSng! = IfFalse!
End Function

'Double
Function IIFDbl# (Condition, IfTrue#, IfFalse#)
    If Condition Then IIFDbl# = IfTrue# Else IIFDbl# = IfFalse#
End Function

'Float
Function IIFF## (Condition, IfTrue##, IfFalse##)
    If Condition Then IIFF## = IfTrue## Else IIFF## = IfFalse##
End Function

'Unsigned Integer
Function IIFUI~% (Condition, IfTrue~%, IfFalse~%)
    If Condition Then IIFUI~% = IfTrue~% Else IIFSTR$ = IfFalse~%
End Function

'Etc.
Reply


Messages In This Thread
_IIF limits two questions - by doppler - 12-20-2024, 07:06 PM
RE: _IIF limits two questions - by Petr - 12-20-2024, 08:03 PM
RE: _IIF limits two questions - by bplus - 12-20-2024, 09:07 PM
RE: _IIF limits two questions - by doppler - 12-21-2024, 02:00 AM
RE: _IIF limits two questions - by Pete - 12-20-2024, 11:44 PM
RE: _IIF limits two questions - by Pete - 12-21-2024, 12:02 AM
RE: _IIF limits two questions - by madscijr - 12-22-2024, 08:49 PM
RE: _IIF limits two questions - by bplus - 12-21-2024, 02:56 AM
RE: _IIF limits two questions - by a740g - 12-23-2024, 01:15 AM
RE: _IIF limits two questions - by madscijr - 12-23-2024, 03:53 AM



Users browsing this thread: 1 Guest(s)