You can create a custom exception and throw them during the execution of your function. As a general practice you should only throw an exception when your function could not achieve its defined functionality.
Private Function OpenDatabase(Byval Server as String, Byval User as String, Byval Pwd as String)
if Server.trim="" then
Throw new Exception("Server Name cannot be blank")
elseif User.trim ="" then
Throw new Exception("User name cannot be blank")
elseif Pwd.trim="" then
Throw new Exception("Password cannot be blank")
endif
'Here add codes for connecting to the server
End function