Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 30th, 2008, 02:59 PM
Registered User
Join Date: Oct 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default return collection by function in class

Hi friends,
I created a VB class with function in visual studio 2005.I got error that can not convert vb system collection.
I am a new person to learn VB studio. I do not know to fix it.
I want to return a 2 dimensional list ( name and id ) without bound
hardcode sets to 10 for test purpose.
Please review my codes

Public Class student
    Private m_studentname As String
    Private m_studentid As String
    Public Property studentname() As String
            Return Me.m_studentname
        End Get
        Set(ByVal valuename As String)
            Me.m_studentname = valuename
        End Set
    End Property

    Public Property studentid() As String
            Return Me.m_studentid
        End Get
        Set(ByVal valueid As String)

            Me.m_studentid = valueid
        End Set
    End Property
    Public Sub New(ByVal studentname As String, ByVal studentid As String)
        Me.studentname = studentname
        Me.studentid = studentid
    End Sub
    Public Function getstudent() As Collection
        Dim vn As String = Me.studentname
        Dim vid As String = Me.studentid
        Dim sb As New sortedlist(Of String, String)
        For i As Integer = 1 To 10
            vn = "jimmy" & i
            vid = "1111" & i
            sb.Add(vn, vid)
            'Messagebox.show(vn & "----" & vid, "debug info")
        Return sb
    End Function
End Class

Old July 30th, 2008, 03:18 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts


Answered in ".NET / Visual Studio 2005" forum.

Please don't crosspost the same question to more than one forum unless you at least say you are doing so.

Similar Threads
Thread Thread Starter Forum Replies Last Post
function return collection in class by VB jimusa Visual Studio 2005 1 July 30th, 2008 03:12 PM
Collection Class chapter 5 eggspencer BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 1 November 27th, 2006 04:46 PM
Return Collection object from a Web Method raybo .NET Web Services 2 June 17th, 2006 07:42 AM
How do I make a function return a class? vertigo VB How-To 3 November 3rd, 2004 06:08 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.