Click here to Skip to main content
15,914,608 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Functions - Parameter Passing Pin
mikasa4-Feb-03 8:41
mikasa4-Feb-03 8:41 
GeneralRe: Functions - Parameter Passing Pin
xBlitzerx4-Feb-03 9:24
xBlitzerx4-Feb-03 9:24 
Generalword, save Pin
pnpfriend1-Feb-03 8:43
pnpfriend1-Feb-03 8:43 
GeneralRe: word, save Pin
Torsten Mauz3-Feb-03 6:43
Torsten Mauz3-Feb-03 6:43 
QuestionVB 6 SQL problem ??? Pin
mixahlos31-Jan-03 15:07
mixahlos31-Jan-03 15:07 
AnswerRe: VB 6 SQL problem ??? Pin
Ray Cassick31-Jan-03 18:42
Ray Cassick31-Jan-03 18:42 
GeneralInheritance question… Pin
Ray Cassick31-Jan-03 9:43
Ray Cassick31-Jan-03 9:43 
GeneralRe: Inheritance question… Pin
Richard Deeming3-Feb-03 3:23
mveRichard Deeming3-Feb-03 3:23 
You can use TypeOf(Me):
Public Class Animal
    Public Sub Bark()
        If TypeOf(Me) Is Dog Then
            Console.WriteLine("Bark!")
        Else
            Console.WriteLine("I can't bark!")
        End If
    End Sub
End Class
 
Public Class Dog : Inherits Animal
    
End Class
However, this is very bad design. You should provide generic functionality in the base class, and then override or extend that functionality in the derived class:
Public Class Animal
    Public Overridable Sub Bark()
        Console.WriteLine("I can't bark!")
    End Sub
End Class
 
Public Class Dog : Inherits Animal
    Public Overrides Sub Bark()
        Console.WriteLine("Bark!")
    End Sub
End Class
If you can't provide generic functionality in the base class, you can make the method abstract (MustOverride):
Public MustInherit Class Animal
    Public MustOverride Sub Bark()
End Class
 
Public Class Dog : Animal
    Public Overrides Sub Bark()
        Console.WriteLine("Bark!")
    End Sub
End Class
If the functionality is not applicable to all classes derived from the base class, consider removing it from the base class. For example, you wouldn't want your Cat class to have a Bark method!


"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
GeneralRe: Inheritance question… Pin
Ray Cassick6-Feb-03 7:21
Ray Cassick6-Feb-03 7:21 
GeneralRe: Inheritance question… Pin
mikasa4-Feb-03 8:50
mikasa4-Feb-03 8:50 
GeneralRe: Inheritance question… Pin
Ray Cassick4-Feb-03 9:37
Ray Cassick4-Feb-03 9:37 
Generalinteger Pin
pnpfriend31-Jan-03 3:57
pnpfriend31-Jan-03 3:57 
GeneralRe: integer Pin
Jason McBurney31-Jan-03 4:41
Jason McBurney31-Jan-03 4:41 
GeneralRe: integer Pin
pnpfriend31-Jan-03 9:29
pnpfriend31-Jan-03 9:29 
GeneralRe: integer Pin
xBlitzerx2-Feb-03 14:36
xBlitzerx2-Feb-03 14:36 
Generalquery on createobject Pin
shanksprasad31-Jan-03 2:03
shanksprasad31-Jan-03 2:03 
GeneralRe: query on createobject Pin
RichardGrimmer5-Feb-03 6:28
RichardGrimmer5-Feb-03 6:28 
GeneralRe: query on createobject Pin
manoj madahavan20-Feb-03 5:22
manoj madahavan20-Feb-03 5:22 
GeneralRe: query on createobject Pin
Paul Farry22-Feb-03 17:23
professionalPaul Farry22-Feb-03 17:23 
Generalproblem updating datagrid Pin
mcm31-Jan-03 1:32
mcm31-Jan-03 1:32 
GeneralRe: problem updating datagrid Pin
Don Benson2-Feb-03 17:00
Don Benson2-Feb-03 17:00 
GeneralRe: problem updating datagrid Pin
Anonymous3-Feb-03 1:20
Anonymous3-Feb-03 1:20 
GeneralRe: problem updating datagrid Pin
Don Benson3-Feb-03 17:03
Don Benson3-Feb-03 17:03 
GeneralCustom Designer... Pin
Julusian30-Jan-03 14:24
Julusian30-Jan-03 14:24 
GeneralPlanet Source Code Visual Basic 2002 CD Pin
shacks30-Jan-03 8:57
shacks30-Jan-03 8:57 

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.