John wrote:
Hi
I am new to classes and trying to get a grip on its concepts. I have a
function defined within a class as below;
Public Class Staff
Public Function CreateUser(ByVal Username As String, ByVal Password As
String, ByVal Email As String, ByVal ErrMsg As String) As Boolean
End Function
End Class
What do I need to do to call this function from elsewhere?
From inside the project that defines the Staff class:
Dim s As New Staff()
If s.CreateUser("Fred", "Password", "fr**@bedrock.com", String.Empty) Then
' OK
End If
Personally, I wouldn't return a Boolean from this. I'd either return
the Error Message and assume all is well if it contains Nothing (or,
possible String.Empty), as in ...
Public Function CreateUser( _
ByVal Username As String _
, ByVal Password As String _
, ByVal Email As String _
) As String
.... or code this as a Sub and throw an Exception if it fails to do its
job, as in
Public Sub CreateUser( _
ByVal Username As String _
, ByVal Password As String _
, ByVal Email As String _
) ' Throws CustomException
HTH,
Phill W.