返回列表 上一主題 發帖

[發問] 怎麼在USERFORM中加入可篩選複選之樹狀圖

大大可能 在 module 漏寫   Public vD  ???

TOP

  Public vD  as object
'
    Private Sub CommandButton1_Click()
        If Application.FindFile = False Then
            MsgBox "您沒有開啟母檔"
        End If

        Dim lRow&
      
      if vD is nothing then  Set vD = CreateObject("Scripting.Dictionary")
        lRow = 3
        vD.RemoveAll
        While Cells(lRow, 1) <> ""
          If Not vD.Exists(CStr(Cells(lRow, 1))) Then
            EXCEL表單處理介面.ListBox1.AddItem CStr(Cells(lRow, 1))
            vD(CStr(Cells(lRow, 1))) = lRow
          End If
          lRow = lRow + 1
        Wend
    End Sub

TOP

回復 13# luhpro

大大說的 "我發現 Excel 上並不能用一個 Is Nothing 就包辦所有這類物件錯誤的判斷"

如果把 Public vD  改成 Public vD  as object

還會出現  Is Nothing  發生問題嗎

蠻好奇的

如果是用 Public vD  
不用 On Err 可以寫成
if  isObject( vD )  then
    if   vD  is Nothing  then
    end if
end if

TOP

回復 15# GBKEE


    http://forum.twbts.com/redirect. ... 0&fromuid=21301

我有改正押   cc....

TOP

回復 39# chaoyiho


    那個訊息代表2意義
(1) 物件不存在註冊表中
(2) 你可能打錯名
答案=(2)
Set a = CreateObject("scripting.dictionary")

TOP

本帖最後由 jackyq 於 2016-4-28 09:12 編輯

回復 44# chaoyiho


Set vD = CreateObject("scripting.dictionary")

你少了一個   i


另外 LongPtr  
用 long 就可以了

TOP

本帖最後由 jackyq 於 2016-4-28 09:30 編輯

EXCEL表單處理介面 裡面的

Private Sub UserForm_Initialize()

Dim hWndForm As LongPtr
Dim IStyle As LongPtr

Set vD = CreateObject("scripting.dictonary")

改成如下

Private Sub UserForm_Initialize()

Dim hWndForm As Long
Dim IStyle As Long

Set vD = CreateObject("scripting.dictionary")


存檔後 , 關閉再重開啟

改完後 我這邊執行就ok 了啊

TOP

另外
把 EXCEL表單處理介面 裡面的第一行   Option Explicit  暫時先拿掉

TOP

再另外
把 EXCEL表單處理介面 裡面的這段 加入藍字部分

Private Sub CommandButton1_Click()
    If Application.FindFile = False Then
        MsgBox "您沒有開啟母檔"
    End If
Dim lRrow&
    lRrow = 3
vD.RemoveAll
While Cells(lRow, 5) <> ""
      If Not vD.Exists(CStr(Cells(lRow, 5))) Then
        EXCEL表單處理介面.ListBox1.AddItem CStr(Cells(lRow, 5))
        vD(CStr(Cells(lRow, 5))) = lRow
      End If
      lRow = lRow + 1
End With
End Sub

TOP

本帖最後由 jackyq 於 2016-4-28 10:26 編輯

回復 52# chaoyiho


#51 樓 我看錯了  ( While  看成 With )
更正一下
大大真的是來考大家眼力的 ( 找不同的遊戲 ?? )

Private Sub CommandButton1_Click()
    If Application.FindFile = False Then
        MsgBox "您沒有開啟母檔"
    End If
Dim lrow&   ' c_c_lai 大大找出
    lrow = 3
vD.RemoveAll
While Cells(lrow, 5) <> ""
      If Not vD.Exists(CStr(Cells(lrow, 5))) Then
        EXCEL表單處理介面.ListBox1.AddItem CStr(Cells(lrow, 5))
        vD(CStr(Cells(lrow, 5))) = lrow
      End If
      lrow = lrow + 1
Wend
End Sub

TOP

        靜思自在 : 有多少力量就做多少事,不要心存等待,等待才會落空。
返回列表 上一主題