|
Subject:
|
Bug in Chapter 5 Personal Organizer
|
|
Posted By:
|
slink
|
Post Date:
|
8/16/2006 3:23:59 PM
|
I made changes to the Personal Organizer program as directed by the book and everything worked as the book said that it would. However, I discovered that if I clicked the "Show List" or "Add Person" buttons more than once before clicking the other button then the program would not display the new control (behaved much like it did prior to step 10 in the try it out).
I'm still green enough in VB 2005 that I don't know why this is happening but I did discover how to prevent it; simply nest the code for each button within another If..Then statement. For the Show List button it would look like this:
If objPersonList Is Nothing Then code as written in the book End If
If a similar addition is made to the Add Person button's code then each button can be clicked as many times as you want before the other button is clicked and everything will behave normally.
|
|
Reply By:
|
Henk-1
|
Reply Date:
|
9/30/2006 12:53:18 PM
|
And where must i placed that code exactly?? tryed several times but can't get it to work.
Regards, Henk
All the best, Henk.
|
|
Reply By:
|
slink
|
Reply Date:
|
10/10/2006 10:52:16 AM
|
Henk,
I've gotten rid of my book and deleted all of the examples that I had out of frustration so this is coming strictly from memory. For the code that I mentioned at the start of this thread I started off with the code exactly as is shown in the book. I then opened up the user interface and double clicked on the button (Show List for this example). This opens up the code viewer right at the point for the code for that button. Right below the "Private Sub . . ." line is where I put the If ..Then statement. I put the End If between the end of the book's code and the "End Sub" line. I then went back to the user interface, double clicked the Add Person button, and added a similar If..Then to that code as well.
As you have probably already found out from the other messages on this board there are a lot of problems with the project presented in this book. This code won't fix any of those problems; it's just something to address a small bug that I found. I recommend forgetting about this book and getting a copy of Microsoft Visual Basic 2005 Step by Step which is written by Michael Halvorson. I had a much easier time with this book and after reading it I was able to write a program for use at my job.
|
|
Reply By:
|
Cry
|
Reply Date:
|
9/9/2007 12:50:23 PM
|
just put pnlMain.Controls.Clear() in place of the entire IF statement of BOTH buttons....
For all you morons that need to trash the authors minor mistake because you're to "stupider" to BE A PROGRAMMER AND figure out what he did wrong..(or the way to fix it with the above line)...HERE IT IS IN EXAMPLE FORM:
Private Sub btnAddPerson_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddPerson.Click objPersonalDetails = New PersonalDetails pnlMain.Controls.Clear() pnlMain.Controls.Add(objPersonalDetails) objPersonalDetails.Dock = DockStyle.Fill End Sub
dang posers....
FYI: Not ever even attempting to program before, I am finding the book relatively easy to follow, and a vast source of knowledge and fun.
Lawrence
|