473,387 Members | 1,582 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,387 software developers and data experts.

Confused by classes (Nightmare!)

I am verry confused about classes. I understand that classes can encapsulate
properties, methods, events (don't know hoy to add events to a class), etc.

I am confused with this: if you can encapsulate all this in a class, how do
you decide or when is it necessary to Dim x as new MyClass or when to use
Imports MyClass. Eather way you have access to all that is inside it.

If I make a class calld User and I want it to handle everything related to
the user: LoginUser, IsLogged, Store the user info. and make that info last
through all the time the app is running how do I get this functionality.

This are my main questions.

If there is a good and understanable document about this please point me to
it.

TIA!
Nov 21 '05 #1
3 1155

"C CORDON"
I am verry confused about classes. I understand that classes can
encapsulate properties, methods, events (don't know hoy to add events to a
class), etc.
Public/Friend Class MyClassA
Friend/Public Event myevent(byval mes as string)
Private sub/function whatever
raise myevent("Hello")
End sub/function
I am confused with this: if you can encapsulate all this in a class, how
do you decide or when is it necessary to Dim x as new MyClass or when to
use Imports MyClass. Eather way you have access to all that is inside it.
These two you have not much to do with each other.

Dim x as new MyClassa (myclass is reserverd a reserved word) is for a class
that looks like this beneath (very ugly written in this as all samples not
nice however written as short as possible)

Public Class MyClassa
Public A as integer
End Class

Than you should first create an object from it what is
dim x as new myClassa
and use it as
x.a = 1
You can make from this as much objects as you want and they are deleted, as
soon as they go out of scoop or/and that there are no references anymore
to/from it, by the Garbage Collector

While you can use a so called shared class that looks like this
Public Class MyClassa
Public shared a as integer
End class

This you can use direct as
MyClassa.x
And this will not be deleted by the Garbage Collector however destroyed with
the program at the end and therefore would be used with care. You would not
make objects from it, this way of using is named "shared class" in VBNet

You can import the last as
import yourprojectname.myclassa
And than you can write
a=1
And become probably everywhere in conflict when you would use "a" :-)
If I make a class calld User and I want it to handle everything related to
the user: LoginUser, IsLogged, Store the user info. and make that info
last through all the time the app is running how do I get this
functionality.

This are my main questions.

I hope that I answered your first question with the "shared class".

I hope this helps something?

Cor
Nov 21 '05 #2
"C CORDON" <tc******@hotmail.com> schrieb:
events (don't know hoy to add events to a class)
Visual Basic Language Concepts -- Events and Delegates
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconEventsDelegatesInheritance.asp>
..NET Framework Developer's Guide -- Handling and Raising Events
<http://msdn.microsoft.com/library/en-us/cpguide/html/cpconevents.asp>
I am confused with this: if you can encapsulate all this in a class, how
do you decide or when is it necessary to Dim x as new MyClass or when to
use Imports MyClass. Eather way you have access to all that is inside it.
By importing a class, you will only get unqualified access to /shared/
members of a class, but not to its instance members.
If I make a class calld User and I want it to handle everything related to
the user: LoginUser, IsLogged, Store the user info. and make that info
last through all the time the app is running how do I get this
functionality.


\\\
Public Module Program
Private m_User As New User()

Public Sub Main()
m_User = New User()
...
Application.Run(New MainForm())
End Sub

Public ReadOnly Property User() As User
Get
Return m_User
End Get
End Property
End Module
///

Access to the user: 'Program.User'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Thnak you verry much for pointing me in the right direction.

Have a little doubt about when shoul it be used buy ill look up some more
information on the web.

Thanks again.
"C CORDON" <tc******@hotmail.com> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
I am verry confused about classes. I understand that classes can
encapsulate properties, methods, events (don't know hoy to add events to a
class), etc.

I am confused with this: if you can encapsulate all this in a class, how
do you decide or when is it necessary to Dim x as new MyClass or when to
use Imports MyClass. Eather way you have access to all that is inside it.

If I make a class calld User and I want it to handle everything related to
the user: LoginUser, IsLogged, Store the user info. and make that info
last through all the time the app is running how do I get this
functionality.

This are my main questions.

If there is a good and understanable document about this please point me
to it.

TIA!

Nov 21 '05 #4

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

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
4
by: Confused Newbie | last post by:
I'm converting an app written in VB 2003 to 2005 and need advice for how to deal with this situation: The app has a number of "manager" classes that handle the data access. They all have...
1
by: DaBrain | last post by:
Thanks for any replies in advance. I am C# Developer messing with VB.NET because I must move MANY Functions on a web site that are written in inline HTML <SCRIPT and I want to put them all in...
2
by: Random | last post by:
Here's a design question I'm curious to know if anyone here has wrestled with before... I'm writing my data access methods in classes in the App_Code directory. I know that I can easily...
29
by: Dom | last post by:
I'm really confused by the difference between a Struct and a Class? Sometimes, I want just a group of fields to go together. A Class without methods seems wrong, in that it carries too much...
12
by: Janaka Perera | last post by:
Hi All, We have done a object oriented design for a system which will create a class multiply inherited by around 1000 small and medium sized classes. I would be greatful if you can help me...
3
by: Glenn | last post by:
My current classic-ASP site has users, projects, roles and the 2.0 membership looks like a perfect fit, but I'm having trouble finding examples of how to have users that belong to different...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.