Sub InitToolBar()
    Dim dir As String
    dir = App.Path() + "\ActivePic\"
    Dim imgX As ImageList
    Set imgX = ImageList1.ListImages.Add(, "do", LoadPicture(dir + "ToolBarDownloadFromServer.bmp"))
           
    Set Toolbar1.ImageList = ImageList1
    
    Dim btnX As Button
    Set btnX = Toolbar1.Buttons.Add(, "do", , tbrDefault, "do")
    btnX.ToolTipText = "ss"
End Sub程序总是在第一个和第三个set处出错,错误信息是:
实时错误'35602'
Key is not unique in collection.
这是个什么问题?谢谢

解决方案 »

  1.   


    上面问题解答:
        Dim imgX As ListImage
        
        Set imgX = ImageList1.ListImages.Add(, "DownloadFromServer", LoadPicture(dir + "ToolBarDownloadFromServer.bmp"))
        
        
        Set Toolbar1.ImageList = ImageList1
        
        Dim btnX As Button
        Set btnX = Toolbar1.Buttons.Add(, "DownLoadFromServer", , tbrDefault, "DownloadFromServer")这个程序第一个set没问题,只是第三个有问题:
    错误类姓‘13’
    类型不匹配
      

  2.   

    应该不是这个问题吧,
    下面的这段程序都有问题?
        Dim myButton As Button
        Set myButton = Toolbar1.Buttons.Add()
        myButton.Key = "ss"错误类姓‘13’
    类型不匹配这下搞不懂了
      

  3.   

    Sub InitToolBar()
        Dim strdir As String
        strdir = App.Path() + "\ActivePic\"
        
        Dim imgX As ListImage
        
        Set imgX = ImageList1.ListImages.Add(, "DownloadFromServer", LoadPicture(strdir + "ToolBarDownloadFromServer.bmp"))
        
        Set Toolbar1.ImageList = ImageList1
       
        Dim myButton As Button
        Set myButton = Toolbar1.Buttons.Add()
        myButton.Key = "ss"
    End Sub我就写了上面的一个Sub,运行到第三个set就出错,类型不匹配!
      

  4.   

    对象的关键字属性(Key)在集合中必须是唯一的
      

  5.   

    是呀,你的Key没问题吧
    类型不匹配?不可能吧,String