开发者

Object returning from Function vb.net

I'm trying to return an object from a function.

E.g. Ive got a function populateDog that returns Dog

So in my aspx class I want to be able to be able to pass in Lassie as the name of the dog(I have a dog class) and have the function return the object with the data it populated.

So that in my aspx class i can go lassie.color, lassie.breed

Main Goal is: lbl.txt = Lassie.Color

Thanks

EDIT

Public Function populateDog(ByVal dName As String) As dog
        dbConnection()
        Dim ObjDog As New dog(dName)
        ObjDog.sBreed = "Collie"
        Return ObjDog
    End Function

The idea was to have a database and I would eventually pass in an ID to query results and return it. For now though I just wanna get this understanding and move fo开发者_JAVA技巧rward.


Public Function populateDog(ByVal dName As String) As dog
        dbConnection()
        Dim ObjDog As New dog(dName)
        ObjDog.sBreed = "Collie"
        ObjDog.Color = "White"
        Return ObjDog
    End Function

and

Dim Lassie as dog
Lassie = populateDog("Lassie")
lbl.Text = Lassie.Color

assuming your dog class is something like

Class dog
    Public sBreed As String
    Public Color As String
    ' other properties and functions
End Class
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜