我是vb6的新手,所以對你們中的一些人可能是顯而易見的。我有一個收集問題,試圖將項目放在集合中,然後評估項目是否存在並將按鈕設置爲啓用或不啓用。vb6集合存在和布爾值集
驗證碼:
For Each vBookmark In lstAssign.SelBookmarks
'---------------------------------------
'filtering with agency code and crew code.
sAssignmentValue = lstAssign.columns("AgencyCode").Value & lstAssign.columns("CrewCode").Value
'Show/hide value depending on crew existance.
If Not ExistsStartLocation(colParameters, sValue) Then
bEnableMyButton = True
colParameters.Add (sValue)
Else
bEnableMyButton = False
End If
'----------------------------------------
Next
sAssignmentValue = ""
tbrMain.TbrButtonEnabled "XXX", bEnableMyButton
tbrMain.TbrButtonEnabled "YYY", bEnable
Set colStartLocationParameters = Nothing
Exit Sub
Private Function ExistsStartLocation(col As collection, index As Variant) As Boolean
On Error GoTo ErrHandler
Dim v As Variant
v = col(index)
ExistsStartLocation = True
Exit Function
ErrHandler:
ExistsStartLocation = False
End Function
的問題是在這一刻,我只有colParameters(指數)接近,所以我不能用值「123 ABC」直接訪問我的收藏。我不想添加一個整數索引,我想繼續簡單地訪問項目值,但我的存在方法將始終返回false。因此始終禁用我的按鈕。
這是如何工作的?
看起來不錯我會試試看看它是否有效。 – X10
您必須對其進行調整,因爲您未發佈任何有關收集可能的方法/屬性的信息... –
colParameters.Add(sValue)字符串值是一個沒有索引的「123-ABC」值,所以每次去它的方法返回錯誤,因爲它只能通過col(Index)而不是col(Value)來訪問。 – X10