Difference between revisions of "Microsoft Access modList"
Jump to navigation
Jump to search
(Created page with '=== storeList === <syntaxhighlight lang="vb"> Public Sub storeList(lst As ListBox) Dim strListIndices As String Dim strListValues As String Dim varIndex As Variant ...') |
|||
Line 1: | Line 1: | ||
+ | === getListIndices === | ||
+ | <syntaxhighlight lang="vb"> | ||
+ | Public Function getListIndices(lst As ListBox) As Variant | ||
+ | Dim varResult As Variant | ||
+ | |||
+ | Dim strListIndices As String | ||
+ | Dim varIndex As Variant | ||
+ | |||
+ | With lst | ||
+ | For Each varIndex In .ItemsSelected | ||
+ | strListIndices = strListIndices & ";" & varIndex | ||
+ | Next | ||
+ | End With | ||
+ | |||
+ | If Len(strListIndices) > 0 Then | ||
+ | strListIndices = Mid(strListIndices, 2) | ||
+ | End If | ||
+ | |||
+ | varResult = Split(strListIndices, ";") | ||
+ | |||
+ | getListIndices = varResult | ||
+ | End Function | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === getListValues === | ||
+ | <syntaxhighlight lang="vb"> | ||
+ | Public Function getListValues(lst As ListBox) As Variant | ||
+ | Dim varResult As Variant | ||
+ | |||
+ | Dim strListValues As String | ||
+ | Dim varIndex As Variant | ||
+ | |||
+ | With lst | ||
+ | For Each varIndex In .ItemsSelected | ||
+ | strListValues = strListValues & ";" & .ItemData(varIndex) | ||
+ | Next | ||
+ | End With | ||
+ | |||
+ | If Len(strListValues) > 0 Then | ||
+ | strListValues = Mid(strListValues, 2) | ||
+ | End If | ||
+ | |||
+ | varResult = Split(strListValues, ";") | ||
+ | |||
+ | getListValues = varResult | ||
+ | End Function | ||
+ | </syntaxhighlight> | ||
+ | |||
=== storeList === | === storeList === | ||
<syntaxhighlight lang="vb"> | <syntaxhighlight lang="vb"> |
Latest revision as of 11:50, 30 September 2010
getListIndices
Public Function getListIndices(lst As ListBox) As Variant
Dim varResult As Variant
Dim strListIndices As String
Dim varIndex As Variant
With lst
For Each varIndex In .ItemsSelected
strListIndices = strListIndices & ";" & varIndex
Next
End With
If Len(strListIndices) > 0 Then
strListIndices = Mid(strListIndices, 2)
End If
varResult = Split(strListIndices, ";")
getListIndices = varResult
End Function
getListValues
Public Function getListValues(lst As ListBox) As Variant
Dim varResult As Variant
Dim strListValues As String
Dim varIndex As Variant
With lst
For Each varIndex In .ItemsSelected
strListValues = strListValues & ";" & .ItemData(varIndex)
Next
End With
If Len(strListValues) > 0 Then
strListValues = Mid(strListValues, 2)
End If
varResult = Split(strListValues, ";")
getListValues = varResult
End Function
storeList
Public Sub storeList(lst As ListBox)
Dim strListIndices As String
Dim strListValues As String
Dim varIndex As Variant
With lst
For Each varIndex In .ItemsSelected
strListIndices = strListIndices & ";" & varIndex
strListValues = strListValues & ";" & .ItemData(varIndex)
Next
If Len(strListIndices) > 0 Then
strListIndices = Mid(strListIndices, 2)
End If
SaveSetting getProjectName, "RunTime", .Name & ".ListIndices", strListIndices
If Len(strListValues) > 0 Then
strListValues = Mid(strListValues, 2)
End If
SaveSetting getProjectName, "RunTime", .Name & ".ListValues", strListValues
End With
End Sub
restoreListValues
Public Sub restoreListValues(lst As ListBox)
Dim strListValues As String
Dim varValues As Variant
Dim varValue As Variant
Dim varListIndex As Long
strListValues = GetSetting(getProjectName, "RunTime", lst.Name & ".ListValues", "")
varValues = Split(strListValues, ";", -1, vbTextCompare)
With lst
For varListIndex = 0 To .ListCount - 1
.Selected(varListIndex) = False
For Each varValue In varValues
If .ItemData(varListIndex) = varValue Then
.Selected(varListIndex) = True
Exit For
End If
Next
Next
End With
End Sub
=== restoreListIndices ===
<syntaxhighlight lang="vb">
Public Sub restoreListIndices(lst As ListBox)
Dim strListIndices As String
Dim varIndices As Variant
Dim varIndex As Variant
Dim varListIndex As Long
strListIndices = GetSetting(getProjectName, "RunTime", lst.Name & ".ListIndices", "")
varIndices = Split(strListIndices, ";", -1, vbTextCompare)
With lst
For varListIndex = 0 To .ListCount - 1
.Selected(varListIndex) = False
For Each varIndex In varIndices
If varListIndex = varIndex Then
.Selected(varListIndex) = True
Exit For
End If
Next
Next
End With
End Sub