【发布时间】:2020-07-09 15:01:53
【问题描述】:
我的用户表单上有一个多列表,用户最多可以选择三个项目。我想捕获第一个选定的项目并将其存储到变量病理结果中,以显示在下一个表单上。如何存储列表中的第一个选定值?这是我比较值的内容
If Me.OptCompare.Value = True Then 'storing value if the chooses to compare
isFirst = False
For i = 0 To Me.lstDiagnosis.ListCount - 1
If isFirst = False Then
If Me.lstDiagnosis.Selected(i) Then
comp = Me.lstDiagnosis.List(i, 0): isFirst = True
Else
If Me.lstDiagnosis.Selected(i) Then
comp = comp & " vs. " & Me.lstDiagnosis.List(i, 0)
End If
End If
Next
Result = comp
PathologyResults = "The pathology is the first selected, " & "."
End If
【问题讨论】:
-
你的两个 if 语句还没有关闭,你能把它们添加到正确的地方
-
那个
Else/If需要和ElseIf在同一行