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
RE: _IIF limits two questions - by NakedApe - 01-20-2025, 01:19 AM
RE: _IIF limits two questions - by OldMoses - 05-13-2025, 05:11 PM
RE: _IIF limits two questions - by a740g - 05-13-2025, 10:51 PM
RE: _IIF limits two questions - by OldMoses - 05-13-2025, 11:38 PM
RE: _IIF limits two questions - by madscijr - 05-13-2025, 11:48 PM
RE: _IIF limits two questions - by SMcNeill - 05-13-2025, 11:55 PM
RE: _IIF limits two questions - by madscijr - 05-14-2025, 05:31 AM
RE: _IIF limits two questions - by CharlieJV - 05-14-2025, 12:56 PM
RE: _IIF limits two questions - by madscijr - 05-14-2025, 04:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What limits you? Unseen Machine 9 1,029 09-05-2025, 01:32 AM
Last Post: madscijr
  Half baked pipe dream questions - hardware and os Parkland 9 1,335 05-23-2025, 03:00 PM
Last Post: madscijr
  IDE suggestions / editor questions madscijr 14 2,365 05-01-2025, 12:56 PM
Last Post: madscijr
  Questions about INSTR Circlotron 7 1,038 04-27-2025, 03:12 PM
Last Post: mdijkens
  Just a Few Questions TarotRedhand 15 2,897 09-11-2023, 12:10 PM
Last Post: DSMan195276

Forum Jump:


Users browsing this thread: 2 Guest(s)