September 23, 2018
Hot Topics:

Visual Basic Tutorial - Part 5

  • November 5, 2002
  • 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!"
  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

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

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

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


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