vb 中怎么才能使 listbox 只能单选。我现在要做的是一个excel中有个listbox但是只能多选。在线等。。。。
我的代码PrivateSubCommandButton1_Click()DimResultsAsStringDimisTheFirstAsBooleanisTheFirs...
我的代码
Private Sub CommandButton1_Click()
Dim Results As String
Dim isTheFirst As Boolean
isTheFirst = True
For i = 0 To UserForm3.ListBoxRemainingOil.ListCount - 1
If UserForm3.ListBoxRemainingOil.Selected(i) = True Then
If isTheFirst = False Then
Results = Results & "; " & UserForm3.ListBoxRemainingOil.List(i)
Else
Results = UserForm3.ListBoxRemainingOil.List(i)
End If
isTheFirst = False
End If
Next
If Len(Results) > 0 Then
Results = UCase(Left(Results, 1)) & Right(Results, Len(Results) - 1)
End If
Sheet1.Range("B40").Value = Results
Unload Me
End Sub 展开
Private Sub CommandButton1_Click()
Dim Results As String
Dim isTheFirst As Boolean
isTheFirst = True
For i = 0 To UserForm3.ListBoxRemainingOil.ListCount - 1
If UserForm3.ListBoxRemainingOil.Selected(i) = True Then
If isTheFirst = False Then
Results = Results & "; " & UserForm3.ListBoxRemainingOil.List(i)
Else
Results = UserForm3.ListBoxRemainingOil.List(i)
End If
isTheFirst = False
End If
Next
If Len(Results) > 0 Then
Results = UCase(Left(Results, 1)) & Right(Results, Len(Results) - 1)
End If
Sheet1.Range("B40").Value = Results
Unload Me
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询