Visual Basic Tutorial - Part 5, Page 4
Functions needn't be simple. Karl explains some practical uses for functions...
Don't forget that a function doesn't have to be as simple as ours. It could contain dozens of lines - perhaps looking in a database of logged-on users and returning a True/False value depending on whether the user is in the table. The function code would go something like this
- Log onto database
- Open logon table
- Check if user is in list
- If user is in table, set the function value to True - otherwise set it to False
Of course, that's all pseudo-code. Real life coding ain't that simple. Hey, comon - ce la vie!
Then you could use the function like this -
If UserLoggedOn("Jane")=True then MsgBox "Jane is logged on!" Else MsgBox "Jane isn't logged on. Sorry!" End If
Whew! That's a lot to take in. But when you figure out the absolute simplicity of the entire function concept - you'll have sussed Visual Basic. Well done!
Page 4 of 5