title: VBA TreeView Node DoubleClick Workaround
body: <p>I have a TreeView within a UserForm in Excel.
  I'm trying to workaround an event handler for double-click in a node since the nodes in tree views only have single click event. The double click in a node will add the double clicked node to a listbox.
  My idea is to check the second click by using the single click event and timers associated with public variables.</p>
  
  <p>I'm finding an issue with this workaround. It's not delivering the desired results for a double click... only for a triple click!</p>
  
  <p>Can anyone please give me some tips about how to solve this issue?
  The double click event for a node is important for what I'm trying to achieve.</p>
  
  <p>Code:</p>
  
  <p>Public/Module Constants/Variables</p>
  
  <pre><code>Const sDblClickTime As Double = 1 'DblClick time
  Dim d1ClickTime As Double '1st click timer
  Dim d2ClickTime As Double '2nd click timer
  Dim sClickNode As String '1st click node text
  </code></pre>
  
  <p>Single Click Node Event</p>
  
  <pre><code>Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
  
  If Node.Text = sClickNode Then
      d2ClickTime = Timer
      If (d2ClickTime - d1ClickTime) &lt;= sDblClickTime Then
          frm.ListBox1.AddItem (Node.Text)
          sClickNode = ""
      Else
          d1ClickTime = Timer
      End If
  Else
      sClickNode = Node.Text
      d1ClickTime = Timer
  End If
  
  End Sub
  </code></pre>