Getting the selected value from a TreeView control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having problems getting the currently selected node out of a TreeView
control.

I currently have:

Dim key As String
key = Mid(Me.treeBranches.SelectedItem.key, 0,
Len(Me.treeBranches.SelectedItem.key) - 2)

Me.description = key

where "treeBranches" is the name of my treeview control. I'm attempting to
get the key except for the last two characters, but I keep getting an
"Invalid procedure call or argument"

Thanks for the help

Andy
 
Have you tried setting the start position to 1 rather than 0?

I would use Left( ) instead of Mid( ). You don't really need to rewrite the
whole thing the way I have done below, but this is probably more readable,
and addresses (although only mimimally) the case where the key is shorter
than you think it should be.

Dim key As String
key = Me.treeBranches.SelectedItem.key
If len(key) < 2 then
msgbox "invalid key: " & key
else
key = left(key, len(key) - 2)
end if
Me.description = key

HTH
Dale
 
Back
Top