Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 by Thearon Willis, Bryan Newsome; ISBN: 9780764574016
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 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 April 30th, 2007, 09:23 AM
Authorized User
 
Join Date: Apr 2007
Posts: 19
Thanks: 4
Thanked 0 Times in 0 Posts
Default (Collection) appears in the list box

I don't know if this is the correct forum for: 0-7645-7401-9 Wrox Beginning Visual Basic 2005.
If it is not can anyone direct me to the correct forum?
If so: Working with Structures page 150-152:
"(Collection)" appears 3 times in the list box instead of the Customer Entries.
I think I have typed the "Try It Out Using an ArrayList" as the book describes.
Can anyone show me were I am in error?
Thanks, Tracey
MSVS2005 Pro AE on Win2K.
ISBN: 0-7645-7401-9 Wrox Beginning Visual Basic 2005.
BTW:
I had to comment out objNewCustomers.Add(objCustomers): 'Add' is not a member of 'StructureDemo.Customer'
... and ...
Try It Out (Overriding ToString) on page 152 does NOT resolve/change anything:
Public Overrides Function ToString() As String
  Return Name & " (" & Email & ")"
End Function


Form1.vb
Public Class Form1
  Private objCustomers As New ArrayList
  Public Sub CreateCustomer(ByVal firstName As String, ByVal lastName As String, ByVal email As String)
     Dim objNewCustomers As Customer
     objNewCustomers.FirstName = firstName
     objNewCustomers.LastName = lastName
     objNewCustomers.Email = email
     'objNewCustomers.Add(objCustomers)
     lstCustomers.Items.Add(objCustomers)
  End Sub
  Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
     Dim objCustomer As Customer
     objCustomer.FirstName = "Michael"
     objCustomer.LastName = "Dell"
     objCustomer.Email = "[email protected]"
     DisplayCustomer(objCustomer)
     CreateCustomer("Darrel", "Hilton", "[email protected]")
     CreateCustomer("Frank", "Peoples", "[email protected]")
     CreateCustomer("Bill", "Scott", "[email protected]")
  End Sub
  Public Sub DisplayCustomer(ByVal customer As Customer)
     txtName.Text = customer.Name
     txtFirstName.Text = customer.FirstName
     txtLastName.Text = customer.LastName
     txtEmail.Text = customer.Email
  End Sub
End Class

Customer.vb
Public Structure Customer
  Public FirstName As String
  Public LastName As String
  Public Email As String
  Public ReadOnly Property Name() As String
     Get
        Return FirstName & " " & LastName
     End Get
  End Property
  Public Overrides Function ToString() As String
     Return Name & " (" & Email & ")"
  End Function
End Structure
__________________
Tracey
 
Old April 30th, 2007, 09:53 AM
Authorized User
 
Join Date: Apr 2007
Posts: 19
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I discovered a type-o

I guess I had to walk away and do something else in order to clear my mind.

Tracey

Tracey





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reporting Services Login box appears zulf BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 6 August 30th, 2011 06:16 AM
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM





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