Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 30th, 2008, 02:59 PM
Registered User
Join Date: Oct 2005
Location: Rockville, MD, USA.
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

Reply With Quote
  #2 (permalink)  
Old July 30th, 2008, 03:18 PM
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
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.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 04:26 AM.

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