Dec 12, 2014 Replies: 7 Hey guys, I just want to share a useful function I created: Code: Sub IfTrue(check_var As Boolean, true_result As Object, false_result As Object) As String If check_var = True Then Return true_result Else Return false_result End If End Sub Usage: Code: Dim This_Glass_Is_Full = True as Boolean ... label1.text = "The glass is " & IfTrue(This_Glass_Is_Full, "full. Click here to drink.", "empty. Click here to refill.") Output: The glass is full. Click here to drink. (This_Glass_Is_Full = True) The glass is empty. Click here to refill. (This_Glass_Is_Full = False) Last edited: Dec 12, 2014 Click to expand...
Hey guys, I just want to share a useful function I created: Code: Sub IfTrue(check_var As Boolean, true_result As Object, false_result As Object) As String If check_var = True Then Return true_result Else Return false_result End If End Sub Usage: Code: Dim This_Glass_Is_Full = True as Boolean ... label1.text = "The glass is " & IfTrue(This_Glass_Is_Full, "full. Click here to drink.", "empty. Click here to refill.") Output: The glass is full. Click here to drink. (This_Glass_Is_Full = True) The glass is empty. Click here to refill. (This_Glass_Is_Full = False)
Cableguy Expert Licensed User Longtime User Dec 12, 2014 #2 Interesting usage... I never thought we could do logical testing within a string set parameter.
wonder Expert Licensed User Longtime User Dec 12, 2014 #3 The world is full of undiscovered possibilities...
M Mahares Expert Licensed User Longtime User Dec 12, 2014 #4 Not to take away from your great effort, but the immediate if function has been documented almost 3 years ago. Please see this link: https://www.b4x.com/android/forum/threads/iif.15363/#post-161305
Not to take away from your great effort, but the immediate if function has been documented almost 3 years ago. Please see this link: https://www.b4x.com/android/forum/threads/iif.15363/#post-161305
wonder Expert Licensed User Longtime User Dec 12, 2014 #5 Mahares said: Not to take away from your great effort, but the immediate if function has been documented almost 3 years ago. Please see this link: https://www.b4x.com/android/forum/threads/iif.15363/#post-161305 Click to expand... Great... Looks like I just "reinvented the wheel".
Mahares said: Not to take away from your great effort, but the immediate if function has been documented almost 3 years ago. Please see this link: https://www.b4x.com/android/forum/threads/iif.15363/#post-161305 Click to expand... Great... Looks like I just "reinvented the wheel".
JakeBullet70 Well-Known Member Licensed User Longtime User Dec 12, 2014 #6 wonder said: Great... Looks like I just "reinvented the wheel". Click to expand... Yeah you did but... NICE!!!
wonder said: Great... Looks like I just "reinvented the wheel". Click to expand... Yeah you did but... NICE!!!
Cableguy Expert Licensed User Longtime User Dec 13, 2014 #7 wonder said: Great... Looks like I just "reinvented the wheel". Click to expand... Even the wheel keeps getting reinvented... From stone to wood, from wood to steel... Then " someone" added rubber to that equation and we got tubed wheels... Yours is like... Tubeless and flat-proof!!!
wonder said: Great... Looks like I just "reinvented the wheel". Click to expand... Even the wheel keeps getting reinvented... From stone to wood, from wood to steel... Then " someone" added rubber to that equation and we got tubed wheels... Yours is like... Tubeless and flat-proof!!!