dcsimg
September 22, 2020
Hot Topics:

Visual Basic Tutorial - Part 5

  • By Karl Moore
  • Send Email »
  • More Articles »

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



This article was originally published on November 6, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.


Thanks for your registration, follow us on our social networks to keep up-to-date