Click here to Skip to main content
15,889,462 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Login Project Help... Pin
Simon_Whale18-Apr-11 5:31
Simon_Whale18-Apr-11 5:31 
QuestionProject Help! Pin
Member 784273314-Apr-11 16:15
Member 784273314-Apr-11 16:15 
AnswerRe: Project Help! Pin
Luc Pattyn15-Apr-11 0:17
sitebuilderLuc Pattyn15-Apr-11 0:17 
AnswerRe: Project Help! Pin
_Erik_18-Apr-11 3:19
_Erik_18-Apr-11 3:19 
Questionvisual basic data report Pin
sandeepkumardadwal11-Apr-11 19:30
sandeepkumardadwal11-Apr-11 19:30 
AnswerRe: visual basic data report Pin
Abhinav S11-Apr-11 21:00
Abhinav S11-Apr-11 21:00 
AnswerRe: visual basic data report Pin
thatraja12-Apr-11 18:36
professionalthatraja12-Apr-11 18:36 
QuestionBest way to return class at runtime - based on value Pin
DeepToot7-Apr-11 7:23
DeepToot7-Apr-11 7:23 
I have a task that is being repeated throughout the application many times. My goal is to take those methods and consolidate it into a Global method.

The problem I am running into is that each task uses a different class type.

My thoughts were to create a method, say IncrementLine(), passing in as a parameter an Enum that would tell it what class it is coming from (Rooms or Library for instance).

This is an example of the existing code from one of these methods: (Also this is the exact code I need to change to bring back different classes, instead of RoomData it could be LibraryData - instead of Room it could be Library)

Dim lstRooms As List(Of RoomData) = Room.LoadAllForLibrary(libraryID)


The code for each of my methods that call IncrementLine() have their own classes like RoomData and Room. With the exception of the code above the rest of the method codes are identical.

Without using a bunch of Selects to determine what Class I should use..how can I return the proper class based on the enum passed in?


I was thinking of maybe using a Generic Delegate Class..something like this:
Public Function ReturnClass(Of t)(ByVal _lType As ListType) As t

End Function


based on what enum value they place it would send back the correct class..however, once I created this class I realized I'd still have to do a Select to determine what ListType they provided.

So my question is, how can I change the code above to be dynamic in returning the proper class based on the enum?

Thanks
AnswerRe: Best way to return class at runtime - based on value Pin
Ali Al Omairi(Abu AlHassan)7-Apr-11 11:16
professionalAli Al Omairi(Abu AlHassan)7-Apr-11 11:16 
AnswerRe: Best way to return class at runtime - based on value Pin
Eddy Vluggen8-Apr-11 0:31
professionalEddy Vluggen8-Apr-11 0:31 
GeneralRe: Best way to return class at runtime - based on value Pin
Ali Al Omairi(Abu AlHassan)10-Apr-11 10:06
professionalAli Al Omairi(Abu AlHassan)10-Apr-11 10:06 
GeneralRe: Best way to return class at runtime - based on value Pin
DeepToot11-Apr-11 4:05
DeepToot11-Apr-11 4:05 
QuestionWrite special cahrs from database to text file using vb.net Pin
vijay24825-Apr-11 5:30
vijay24825-Apr-11 5:30 
AnswerRe: Write special cahrs from database to text file using vb.net Pin
Luc Pattyn5-Apr-11 5:53
sitebuilderLuc Pattyn5-Apr-11 5:53 
GeneralRe: Write special cahrs from database to text file using vb.net Pin
Thomas Krojer5-Apr-11 21:05
Thomas Krojer5-Apr-11 21:05 
GeneralRe: Write special cahrs from database to text file using vb.net Pin
vijay24825-Apr-11 21:41
vijay24825-Apr-11 21:41 
GeneralRe: Write special cahrs from database to text file using vb.net Pin
riced5-Apr-11 23:36
riced5-Apr-11 23:36 
GeneralRe: Write special cahrs from database to text file using vb.net Pin
vijay24826-Apr-11 0:05
vijay24826-Apr-11 0:05 
Questionfind window lock time and unlock time? Pin
kartheeee5-Apr-11 1:23
kartheeee5-Apr-11 1:23 
AnswerRe: find window lock time and unlock time? Pin
dan!sh 5-Apr-11 1:45
professional dan!sh 5-Apr-11 1:45 
AnswerRe: find window lock time and unlock time? Pin
Dave Kreskowiak5-Apr-11 4:04
mveDave Kreskowiak5-Apr-11 4:04 
QuestionTasks Scheduler issue Pin
mli.ahmed4-Apr-11 19:25
mli.ahmed4-Apr-11 19:25 
GeneralRe: Tasks Scheduler issue Pin
thatraja4-Apr-11 20:13
professionalthatraja4-Apr-11 20:13 
GeneralRe: Tasks Scheduler issue Pin
mli.ahmed4-Apr-11 20:56
mli.ahmed4-Apr-11 20:56 
GeneralRe: Tasks Scheduler issue Pin
Dave Kreskowiak5-Apr-11 4:07
mveDave Kreskowiak5-Apr-11 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.