VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Begin VB.Form frmExplore Caption = "VI Explorer" ClientHeight = 6915 ClientLeft = 60 ClientTop = 345 ClientWidth = 9495 LinkTopic = "Form1" ScaleHeight = 6915 ScaleWidth = 9495 StartUpPosition = 3 'Windows Default Begin MSComctlLib.TreeView tvExplorer Height = 4290 Left = 135 TabIndex = 0 Top = 150 Width = 8685 _ExtentX = 15319 _ExtentY = 7567 _Version = 393217 Indentation = 176 LabelEdit = 1 Sorted = -1 'True Style = 6 FullRowSelect = -1 'True SingleSel = -1 'True Appearance = 1 Enabled = 0 'False BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Verdana" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty OLEDragMode = 1 OLEDropMode = 1 End End Attribute VB_Name = "frmExplore" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() LoadTree End Sub Sub LoadTree() If Not dbOpen Then Exit Sub Dim rs As ADODB.Recordset Dim ors As ADODB.Recordset Dim PIndex As Integer Dim PLIndex As Integer Dim PUIndex As Integer Dim ALIndex As Integer Dim AUIndex As Integer Dim OIndex As Integer Dim OLIndex As Integer Dim OUIndex As Integer Dim CIndex As Integer Dim gIndex As Integer Dim NewIndex As Integer Dim NewKey As Integer Dim NewSubKey As Integer Dim mNode As Node Set mNode = tvExplorer.Nodes.Add() With mNode .Text = "TestGame" .Key = "Root" .Expanded = True End With PIndex = 1 With tvExplorer.Nodes Set mNode = .Add(PIndex, tvwChild, "Prop", "Properties") PropIndex = mNode.Index Set mNode = .Add(PropIndex, tvwChild, "Lib", "Library") PLIndex = mNode.Index Set mNode = .Add(PropIndex, tvwChild, "User", "User") PUIndex = mNode.Index Set mNode = .Add(PIndex, tvwChild, "Attrib", "Attributes") AIndex = mNode.Index Set mNode = .Add(PIndex, tvwChild, "Obj", "Objects") OIndex = mNode.Index Set mNode = .Add(OIndex, tvwChild, "ObjLib", "Library") OLIndex = mNode.Index Set mNode = .Add(OIndex, tvwChild, "ObjUser", "User") OUIndex = mNode.Index Set mNode = .Add(PIndex, tvwChild, "Cls", "Classes") CIndex = mNode.Index Set mNode = .Add(CIndex, tvwChild, "ClsLib", "Library") CLIndex = mNode.Index Set mNode = .Add(CIndex, tvwChild, "ClsUser", "User") CUIndex = mNode.Index Set mNode = .Add(PIndex, tvwChild, "Grm", "Grammar") gIndex = mNode.Index Set mNode = .Add(AIndex, tvwChild, "ALib", "Library") ALIndex = mNode.Index Set mNode = .Add(AIndex, tvwChild, "AUser", "User") AUIndex = mNode.Index ' ' Attributes ' Set rs = dbConn.Execute("SELECT * FROM Attribute") Do Until rs.EOF If rs("SpaceNumber") = 0 Then NewIndex = ALIndex Else NewIndex = AUIndex End If Set mNode = .Add(NewIndex, tvwChild, "AttributeId " & rs("AttributeId"), rs("AttributeName")) NewKey = mNode.Index ' ' Locate and add Objects ' Set ors = dbConn.Execute("SELECT O.ObjectId, O.ObjectName, O.SpaceNumber FROM ObjectAttribute AS OA, [Object] AS O WHERE (((OA.ObjectId)=[O].[ObjectId]) AND ((OA.AttributeId)=" & rs("AttributeId") & "));") If Not ors.EOF Then Set mNode = .Add(NewKey, tvwChild, "AttributeId " & rs("AttributeId") & " Objects", "Objects") NewSubKey = mNode.Index Do Until ors.EOF .Add NewSubKey, tvwChild, "AttributeId " & rs("AttributeId") & " Objects" & ":" & ors("ObjectId"), ors("ObjectName") ' ' Add to Object\Library-User\ObjectName\Attributes\AttribName ' On Error Resume Next If ors("SpaceNumber") = 0 Then Set mNode = .Add(OLIndex, tvwChild, "ObjLib ObjectId" & ors("ObjectId"), ors("ObjectName")) If Err.Number <> 0 Then NextIndex = .Item("ObjLib ObjectId" & ors("ObjectId")).Index Else NextIndex = mNode.Index End If Set mNode = .Add(NextIndex, tvwChild, "ObjLib ObjectId" & ors("ObjectId") & "Attrib", "Attributes") If Err.Number <> 0 Then NextIndex = .Item("ObjLib ObjectId" & ors("ObjectId") & "Attrib") Else NextIndex = mNode.Index End If .Add NextIndex, tvwChild, "ObjLib ObjectId" & ors("ObjectId") & "Attrib" & rs("AttributeId"), rs("AttributeName") Else Set mNode = .Add(OUIndex, tvwChild, "ObjUser ObjectId" & ors("ObjectId"), ors("ObjectName")) If Err.Number <> 0 Then NextIndex = .Item("ObjUser ObjectId" & ors("ObjectId")).Index Else NextIndex = mNode.Index End If Set mNode = .Add(NextIndex, tvwChild, "ObjUser ObjectId" & ors("ObjectId") & "Attrib", "Attributes") If Err.Number <> 0 Then NextIndex = .Item("ObjUser ObjectId" & ors("ObjectId") & "Attrib") Else NextIndex = mNode.Index End If .Add NextIndex, tvwChild, "ObjUser ObjectId" & ors("ObjectId") & "Attrib" & rs("AttributeId"), rs("AttributeName") End If ors.MoveNext Loop ors.Close Set ors = Nothing End If ' ' Locate and add Classes ' Set ors = dbConn.Execute("SELECT C.ClassId, C.ClassName, C.SpaceNumber FROM ClassAttribute AS CA, Class AS C WHERE CA.ClassId=C.ClassId AND CA.AttributeId=" & rs("AttributeId")) If Not ors.EOF Then Set mNode = .Add(NewKey, tvwChild, "AttributeId " & rs("AttributeId") & " Classes", "Classes") NewSubKey = mNode.Index Do Until ors.EOF .Add NewSubKey, tvwChild, "AttributeId " & rs("AttributeId") & " Classes" & ":" & ors("ClassId"), ors("ClassName") ' ' Add to Object\Library-User\ObjectName\Attributes\AttribName ' On Error Resume Next If ors("SpaceNumber") = 0 Then Set mNode = .Add(CLIndex, tvwChild, "ClsLib ClassId" & ors("ClassId"), ors("ClassName")) If Err.Number <> 0 Then NextIndex = .Item("ClsLib ClassId" & ors("ClassId")).Index Else NextIndex = mNode.Index End If Set mNode = .Add(NextIndex, tvwChild, "ClsLib ClassId" & ors("ClassId") & "Attrib", "Attributes") If Err.Number <> 0 Then NextIndex = .Item("ClsLib ClassId" & ors("ClassId") & "Attrib") Else NextIndex = mNode.Index End If .Add NextIndex, tvwChild, "ClsLib ClassId" & ors("ClassId") & "Attrib" & rs("AttributeId"), rs("AttributeName") Else Set mNode = .Add(CUIndex, tvwChild, "ClsUser ClassId" & ors("ClassId"), ors("ClassName")) If Err.Number <> 0 Then NextIndex = .Item("ClsUser ClassId" & ors("ClassId")).Index Else NextIndex = mNode.Index End If Set mNode = .Add(NextIndex, tvwChild, "ClsUser ClassId" & ors("ClassId") & "Attrib", "Attributes") If Err.Number <> 0 Then NextIndex = .Item("ClsUser ClassId" & ors("ClassId") & "Attrib") Else NextIndex = mNode.Index End If .Add NextIndex, tvwChild, "ClsUser ClassId" & ors("ClassId") & "Attrib" & rs("AttributeId"), rs("AttributeName") End If ors.MoveNext Loop ors.Close Set ors = Nothing End If rs.MoveNext Loop rs.Close Set rs = Nothing ' ' Properties ' Set rs = dbConn.Execute("SELECT * FROM Property") Do Until rs.EOF If rs("SpaceNumber") = 0 Then NewIndex = PLIndex Else NewIndex = PUIndex End If Set mNode = .Add(NewIndex, tvwChild, "PropertyId " & rs("PropertyId"), rs("PropertyName")) NewKey = mNode.Index ' ' Locate and add Objects ' Set ors = dbConn.Execute("SELECT O.ObjectId,O.ObjectName FROM ObjectProperty OP, Object O Where OP.ObjectId=O.ObjectId And OP.PropertyId = " & rs("PropertyId")) If Not ors.EOF Then Set mNode = .Add(NewKey, tvwChild, "PropertyId " & rs("PropertyId") & " Objects", "Objects") NewSubKey = mNode.Index Do Until ors.EOF .Add NewSubKey, tvwChild, "PropertyId " & rs("PropertyId") & " Objects" & ":" & ors("ObjectId"), ors("ObjectName") ors.MoveNext Loop ors.Close Set ors = Nothing End If ' ' Locate and add Classes ' Set ors = dbConn.Execute("SELECT C.ClassId, C.ClassName FROM ClassProperty AS CP, Class AS C WHERE CP.ClassId=C.ClassId AND CP.PropertyId=" & rs("PropertyId")) If Not ors.EOF Then Set mNode = .Add(NewKey, tvwChild, "PropertyId " & rs("PropertyId") & " Classes", "Classes") NewSubKey = mNode.Index Do Until ors.EOF .Add NewSubKey, tvwChild, "PropertyId " & rs("PropertyId") & " Classes" & ":" & ors("ClassId"), ors("ClassName") ors.MoveNext Loop ors.Close Set ors = Nothing End If rs.MoveNext Loop rs.Close Set rs = Nothing Set mNode = Nothing End With End Sub