Spam and If 24 Mar, 2003
Just saw this BBC story about the possibility of spam being canned in two years. Yeah right. Tttthhhhhppppthp.
OK, no more ranting and general obstreperousness. Time to get to some code. Whether it's bad practice to end up in this kind of scenario is a debate for another day, but I came up with a function today that was extremely useful. I had some legacy code with reams of If foo=blah then bar=woo…
nonsense in it. Each If
statement was taking up around 4 - 5 lines (plenty of Else
s too…), and I got bored with it all. It looked plain nasty. This looks much better to my mind:
strTmp = doIF(Isempty(doc.Field) ,"Gah!", doc.Field(0))
The function is very simple, and like I say, is purely for brevity and ease of reading:
Function doIF(intEval As Integer, strThen As String,_
strElse As String) As String
If intEval Then
doIF = strThen
Else
doIF = strElse
End If
End Function
LinkEd Brill#
Those things can take years away. Ah, my wee posts from 1995 when I was [email protected]… and I posted from a Mac Classic with a 28.8 modem (yes! 28.8!!)Ben Poole#
lol, that is my new fave exclamation, right up there with "works a treat!"jonvon#