![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: explanation, help, methods, nonstatic, static |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |
| |||
| A static method can be directly called from an object... whereas a non-static method must instantiate the object first. Non-Static: Dim Chet as New Person("Chet","aaa@bbb.com") Msgbox(Chet.GetFirstName()) Static: Msgbox(Chet.GetFirstName()) - No need to instantiate a Person Obj. but remember that your PRivate members that you rely on to "GetFirstName" must also be static... even if it is Private. Generally if you will build a Utility class that is just all static methods you can directly call that your app or website uses a lot like IsNumeric or IsEmail, etc... __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
| The Following User Says Thank You to ccoonen For This Useful Post: | ||
HelloWorld (09-20-2007) | ||
| |||
| I'm a big fan of Creating your class, having private setters/public getters and have Static Methods in the class to instantiate and return a list of itself Like if you had a class Person imports system.componentmodel Public Class Person Private _FirstName as String Private _LastName as String Public Property FirstName() as String ....... ....... Public Sub New(ByRef FirstName as STring, byref LastName as STring) me.firstname = firstname me.lastname = lastname end sub Public Function GetAllPeople() as BindingList(Of Person) Dim People as new BindingList(Of Person) ' Hit DB and get Datatable of all people For each PDR as PeopleDataRow in PeopleDataTable people.Add(PDR) Next return people end function end class This way it's always a 1liner for you objects directly to a control... then just define what matches what PeopleDropdownList.DataSource = Person.GetAllPeople() PeopleDropdownList.DisplayMember = "FirstName" PeopleDropdownList....... = whatever.... __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
| The Following User Says Thank You to ccoonen For This Useful Post: | ||
HelloWorld (09-23-2007) | ||
![]() |
| Thread Tools | |
| Display Modes | |
| |