About OO in VB

A

ABC

I have one base class (A) and a derived class (B)

Class A
...
...
...
Public Overrides Function GetText() as string
Return "A" & _text
end function

Public Function GetFormatText() as string
a = GetText()
End function
end class

Class B Inherits A
Public Overrides Function GetText() as string
Return "B" & _text
end function
End Class


When I call B.GetFormatText(), it return like as "A....." not my expected
"B....."

How can I fix it?
 
C

Cor Ligthert [MVP]

ABC,

Strange this returns for me "B".

(Maybe can you make next time an error free sample)

\\\
Class A
Public Overridable Function GetText() As String
Return "A"
End Function
Public Function GetFormatText() As String
Return GetText()
End Function
End Class
Class B
Inherits A
Public Overrides Function GetText() As String
Return "B"
End Function
End Class
///

I hope this helps,

Cor
 
A

ABC

Thank you.


Cor Ligthert said:
ABC,

Strange this returns for me "B".

(Maybe can you make next time an error free sample)

\\\
Class A
Public Overridable Function GetText() As String
Return "A"
End Function
Public Function GetFormatText() As String
Return GetText()
End Function
End Class
Class B
Inherits A
Public Overrides Function GetText() As String
Return "B"
End Function
End Class
///

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top