2017-02-27 5 views

答えて

2

次の手順のバリエーションを使用する必要があります。

  1. はフォーム

  2. 上のリストボックスを作成する行ソースを使用して、リストボックスを移入します。

  3. は、私は次のVBA

    Option Compare Database 
    Private Item_IDs as string 
    
    Private Sub List_item_id_Click() 
    Dim i As Integer, count As Integer 
    Dim Item_IDs As String 
    count = 1 
    For i = 0 To Me.List_item_id.ListCount - 1 
        If Me.List_item_id.Selected(i) = True Then 
         Item_IDs = Item_IDs & ", " & Me.List_item_id.ItemData(i) 
         count = count + 1 
        End If 
    Next i 
    Item_IDs = Mid(Item_IDs, 3) 
    Debug.Print Item_IDs 
    
    
    End Sub 
    

    を今、私は、リスト内の値をクリックするたびに、それが返されます使用される他のタブに移動し、拡張

に複数選択プロパティを変更します選択したもののカンマ区切りの値文字列(Item_IDs)。 VBAウィンドウでCTRL + Gを使用して、直接ウィンドウを開き、自分の仕事の成果を確認します。

0

何かが好きです。 。 。

Private Sub OKButton_Click() 
     Dim Msg As String 
     Dim i As Integer 
     Msg = "You selected" & vbNewLine 
     For i = 0 To ListBox1.ListCount - 1 
      If ListBox1.Selected(i) Then 
       Msg = Msg & ListBox1.List(i) & vbNewLine 
      End If 
     Next i 
     MsgBox Msg 
     Unload UserForm1 
    End Sub 
関連する問題