Listbox.value not settig

D

Dave F.

Hi

I got a problem using multiple listboxes.

I have 3 of them: Listbox 1-3
If I click another option in 1 it reloads 2 with new info.
The same if I click in box 2 with box 3.

The marked line >>>>> doesn't set Listbox2.value to anything, just "", even
though there
is a string value in YY(0).nodeName
I'm confused as to why: The same line in UserForm_Initialize works fine.

Any ideas where I'm going wrong?

Thanks
David F.


Option Explicit

Dim MsDom As DOMDocument

Sub UserForm_Initialize()
Dim XX As IXMLDOMNodeList
Dim Itm As IXMLDOMNode

Set MsDom = CreateObject("MSXML.DOMDocument")
MsDom.Load ("c:\dwgs\fx2005\fxlayersXML.xml")
MsDom.async = False

Set XX = MsDom.selectNodes("/layers/*") ' all of selected layers
With ListBox1
For Each Itm In XX
.AddItem Itm.nodeName ' puts each of the layer names into the
lisbox
Next
End With
ListBox1.Value = XX(0).nodeName ' goes to LB2 change
End Sub

Sub ListBox1_Change() ' 1
Dim ChldNode As IXMLDOMNodeList
Dim Itm As IXMLDOMNode
Dim YY As IXMLDOMNodeList

Set YY = MsDom.selectNodes("/layers/" & ListBox1.Value & "/*")
With ListBox2
.Clear ' removes items from listbox2
For Each Itm In YY
.AddItem Itm.nodeName
Next
End With
Debug.Print YY(0).nodeNameset - why?
End Sub

Sub ListBox2_Change() ' 2
Dim Itm As IXMLDOMNode
Dim ZZ As IXMLDOMNodeList

Debug.Print "/layers/" & ListBox1.Value & "/" & ListBox2.Value & "/x "
Set ZZ = MsDom.selectNodes("/layers/" & ListBox1.Value & "/" &
ListBox2.Value & "/x")

With ListBox3
.Clear ' removes items from listbox3
For Each Itm In ZZ
.AddItem Itm.Text ' puts each of the serials sizes into the
lisbox
Next
End With
End Sub ' listbox2 change

Sub CboCancel_Click()
Me.Hide
End Sub
 
D

Dave F.

John
Thanks for replying.

Yes, I'm pretty sure it does because it's the values in YY that are put in
the listbox via Additem.

Could there be a reason they're not the same?

Cheers
Dave F.
 
J

Jonathan West

Dave F. said:
John
Thanks for replying.

Yes, I'm pretty sure it does because it's the values in YY that are put in
the listbox via Additem.

Could there be a reason they're not the same?

I've no idea, but i suggest that you add in a bit of diagnostic code at the
appropriate point to check. What you do is run through each of the items in
ListBox2, something like this

For k = 0 to ListBox2.ListCount - 1
If ListBox2.List(k, 0) = YY(0).nodeName Then
Debug.Print "Item " & k & ", match!"
Else
Debug.Print "Item " & k & ", no match"
End If
Next k

If you don't get a match then you know that there is something wrong.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top