Using “IIf” can make your functions shorter like below:
Sub testIIF() Dim bLong As Boolean Dim bVeryLong as Boolean Dim strName As String strName = "Mazzy" bLong = IIf(Len(strName) > 3, True, False) 'And you can even nest an IIf inside another one like this bVeryLong = IIf(Len(strName) > 3, IIf(Len(strName) > 4, True, False), False) End Sub
And here’s the equivalent code with a regular “If” for the first part:
Sub testIF()
Dim bLong As Boolean
Dim strName As String
strName = "Mazzy"
bLong = False
If Len(strName) > 3 Then
bLong = True
End If
End Sub
Be creative but be careful not to nest too many IIfs because then your code would be very hard to read.
Keep coding!