【问题标题】:How to add a value from a text box to list box five times instantly?如何立即将文本框中的值添加到列表框中五次?
【发布时间】:2021-09-25 14:03:18
【问题描述】:

我喜欢通过单击按钮将 textbox4.value 添加到列表框 5 次。 如果文本框值为yes,我希望列表框列出yes yes yes yes yes。我不知道这是可能的,但我希望如此。

Private Sub CommandButton2_Click()
If Me.TextBox4.Value = "" Then
Exit Sub
Else
ListBox1.AddItem Me.TextBox4.Value
Me.TextBox4.Value = ""
End If
Me.TextBox4.SetFocus
End Sub

【问题讨论】:

    标签: excel vba textbox listbox populate


    【解决方案1】:

    试试:

    Private Sub CommandButton2_Click()
    
    If Me.TextBox4.Value = "" Then
        Exit Sub
    Else
        Dim i As Long
        For i = 1 To 5
            ListBox1.AddItem Me.TextBox4.Value
        Next i
        Me.TextBox4.Value = ""
    End If
    Me.TextBox4.SetFocus
    
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2011-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      相关资源
      最近更新 更多