473,383 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Dumb class question

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?

Thanks

Regards
Jan 7 '07 #1
3 876
First, if you are trying to pass back an error message when the CreateUser
method is called you should define that argument as ByRef instead of ByVal.

Second, you can call it this way.

Dim stf As New Staff
Dim errMsg As String

If (stf.CreateUser("John Doe", "Password", jo*****@domain.com", errMsg) =
False) Then
Debug.Writeline(errMsg)

End If

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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?

Thanks

Regards

Jan 7 '07 #2
"John" <Jo**@nospam.infovis.co.ukwrote in
news:#I**************@TK2MSFTNGP02.phx.gbl:
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?

Thanks

Regards
Dim LazyWaster as Staff
LazyWaster = New Staff()
LazyWaster.CreateUser
Jan 7 '07 #3
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.
Jan 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Duncan Mole | last post by:
Hi, I know this is dumb but if I add a reference to the release version of a company class library in debug and build it it works fine. If I then switch to release and rebuild the reference is...
4
by: Piedro | last post by:
Hi group, as I was browsing the web and checking out w3schools.com I read that the font tag was deprecated and that I should use css styles for formatting like for example <p class="p1"> Text...
2
by: TGF | last post by:
How do you copy a String type into a native char buffer? Dumb question, but not sure how to do it :( TGF
6
by: wASP | last post by:
Hello everyone, I'm new to C# and ASP.NET, so pardon my stupidity on this one. I'm having a problem with referencing methods/functions external to a class member function. My code is as...
11
by: dhnriverside | last post by:
Hi peeps Ok, so I thought I'd have a go at making a console app in VS2k5... I haven't written any windows apps for years, let alone dos apps (been web programming) and I've hit a dumb error... ...
2
by: Derek Martin | last post by:
Not like I haven't asked dumb ones before, but I want to take my API that I designed and create a DLL out of it, instead of it sitting inside my main form. In VS2K3, how do I go about doing...
2
by: Bill Nguyen | last post by:
I would like to add a new VB.NET project using the same folder being used by another project so that I can share several forms already creaded by the other project. However, .NET created a new...
3
by: rdufour | last post by:
Downloaded a sample that is supposed to show how to localize a web site and started playing with the code, its in Vs2003, so I figure I would take code and put it in Vs 2005 and doing so use it a...
10
by: Dick Moores | last post by:
I'm still trying to understand classes. I've made some progress, I think, but I don't understand how to use this one. How do I call it, or any of its functions? It's from the Cookbook, at...
8
by: Keith Rebello | last post by:
I have a program whose main form has a picture box on which concrete column sections are drawn. Input to the drawing is achieved by filling in data in various dialog boxes (called by using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.