我有一个多选列表框,有大约60个值,用户可以通过并选择他们想要的任何东西我可以成功读取所有选中的内容并将其输出为一行,如“1,2,3,4,5”和存储该值。我目前遇到的问题是当用户需要编辑所选内容时。如何根据之前存储的字符串“1,2,3,4,5”重新选择列表框项?
答案 0 :(得分:0)
经过大量搜索后我发现了这个问题,这里是代码
Dim strValue As String
Dim strArray() As String
Dim x As Integer
Dim startRow As Integer
strValue = rsPrints("ctype")'Get string of row values
strArray = Split(strValue, ",", -1, vbTextCompare)'My string required splitting to remove commas and moving to an array
x = 0 'Set array start point to 0
For Q = LBound(strArray) To UBound(strArray) 'Run through array
startRow = strArray(x)
Me.formctype.Selected(startRow) = True
x = x + 1
Next