Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 17th, 2004, 12:58 PM
Authorized User
 
Join Date: Jul 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default ListBox Code Error?

Hi,

On Page 83 the book gives a sample of how to use the <asp:listbox> control. I found the compiler could not recognize that I had declared "msg as string" in the line "If Page.IsPostBack Then Dim msg as string"

I finally took "Dim msg as string" and put it in a separate line above. So here's how my code now reads, and my compiler finally accepted it:

 Dim msg as String
         If Page.IsPostBack then

         If list1.Items(0).Selected Then msg = msg & list1.Items(0).Text & "<br />"
         If list1.Items(1).Selected Then msg = msg & list1.Items(1).Text & "<br />"
         If list1.Items(2).Selected Then msg = msg & list1.Items(2).Text & "<br />"
             If msg <> "" then


Has anyone else found the same problem?

Kara

 
Old July 18th, 2004, 02:03 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Was the code that gave the error all on one line?? If so, you could have moved the Dim statement to the next line as well:
Code:
If Page.IsPostBack then  
  Dim msg as String
  If list1.Items(0).Selected Then msg = msg & list1.Items(0).Text & "<br />"

...

End If
Should work equally well if msg is only used inside the If statement.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple Listbox values in another listbox terryv Excel VBA 0 June 27th, 2007 07:01 AM
error in code bukky Classic ASP Databases 2 March 5th, 2004 07:10 PM
error in code bukky Classic ASP Databases 2 March 5th, 2004 11:29 AM
Error displayed with error trap code stoneman Access 4 February 28th, 2004 02:53 PM
I'm back :) Listbox var from listbox MichaelTJ .NET Web Services 2 October 21st, 2003 07:06 PM





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