Microsoft Knowledge Base Email Alertz

KBAlertz.com: (150704) - The Count property value of the Toolbar Buttons collection is not correct when a button without an image is shown on the Toolbar control.

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 150704 - Last Review: July 13, 2004 - Revision: 2.1

FIX: Toolbar Button Count Is Wrong if Image Index is Invalid

This article was previously published under Q150704

On This Page

SYMPTOMS

The Count property value of the Toolbar Buttons collection is not correct when a button without an image is shown on the Toolbar control.

CAUSE

This behavior occurs if an Invalid image parameter is used with the Add method on an ImageList control. The ImageList control supplies the images for the buttons on the Toolbar control.

RESOLUTION

Use a valid Image index number.

-or-

If you want a button to show without an image, trap the error and leave out the Image parameter in the Add method.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Basic 5.0.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start the 32-bit edition of Visual Basic 4.0. If it is already running, from the File menu, select New Project.
  2. Add a Toolbar control, an Image List control, and a Command button to Form1.
  3. Copy the following code to the Code window of Form1:
          Option Explicit
    
          Private Sub Command1_Click()
             Dim i As Integer
             Dim ImgX As ListImage
             Dim tbButton As Button
    
             Set ImgX = ImageList1.ListImages.Add(, , _
                     LoadPicture("C:\Visual Basic\Icons\Industry\bicycle.ico"))
             ' Modify the argument for the LoadPicture function to point to
             ' directory containing an icon.
    
             On Error Resume Next
             Form1.Toolbar1.ImageList = ImageList1
    
             ' Comment the next line to workaround problem.
             Set tbButton = Form1.Toolbar1.Buttons.Add(1, , "Node1", , 2)
    
             ' Uncomment one of the following lines to workaround problem.
             ' Uncomment this line if you want the image to appear on the
             ' button.
             ' Set tbButton = Form1.Toolbar1.Buttons.Add(1, , "Node1", , 1)
    
             ' Uncomment this line if you want a blank button
             ' Set tbButton = Form1.Toolbar1.Buttons.Add(1, , "Node1")
             MsgBox "Number of Buttons according to Count Property: " & _
                     Toolbar1.Buttons.Count
    
          End Sub
    						
  4. On the Run menu, select Start, or press the F5 key. Click the Command button. A button appears on the Toolbar but the message box indicates no buttons on the Toolbar.

APPLIES TO
  • Microsoft Visual Basic 4.0 Standard Edition
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
Keywords: 
kbbug kbfix kbvbp500fix KB150704
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please