Z
z71mdridin
I have three classes:
Public MustInherit Class Animal
Public MustOverride Function speak() As String
End Class
Public Class dog
Inherits Animal
Public Overrides Function speak() As String
Return "Bark"
End Function
End Class
Public Class cat
Inherits Animal
Public Overrides Function speak() As String
Return "Meow"
End Function
End Class
I want to create a front-end and allow the user to choose dog or cat
from a drop down and then call the appropriate method. Is this
possible to do without using a case statement? I would like to create
an instance of animal and then cast it to whatever the user has
chosen. Is this possible in vb.net?
Dim testanimal As Animal
CType(testanimal, Combobox1.SelectedValue)
testanimal.speak()
Public MustInherit Class Animal
Public MustOverride Function speak() As String
End Class
Public Class dog
Inherits Animal
Public Overrides Function speak() As String
Return "Bark"
End Function
End Class
Public Class cat
Inherits Animal
Public Overrides Function speak() As String
Return "Meow"
End Function
End Class
I want to create a front-end and allow the user to choose dog or cat
from a drop down and then call the appropriate method. Is this
possible to do without using a case statement? I would like to create
an instance of animal and then cast it to whatever the user has
chosen. Is this possible in vb.net?
Dim testanimal As Animal
CType(testanimal, Combobox1.SelectedValue)
testanimal.speak()