home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / VB6_Viewer20275910292006.psc / VB_Editor.frm < prev    next >
Text File  |  2006-11-29  |  28KB  |  912 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  3. Begin VB.Form frmMain 
  4.    BackColor       =   &H0050BEBE&
  5.    Caption         =   "VB Editor   - by PointEqual"
  6.    ClientHeight    =   6555
  7.    ClientLeft      =   2625
  8.    ClientTop       =   6585
  9.    ClientWidth     =   7830
  10.    ClipControls    =   0   'False
  11.    BeginProperty Font 
  12.       Name            =   "Times New Roman"
  13.       Size            =   12
  14.       Charset         =   0
  15.       Weight          =   700
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    KeyPreview      =   -1  'True
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   6555
  25.    ScaleWidth      =   7830
  26.    Begin MSComctlLib.TreeView TRV 
  27.       Height          =   405
  28.       Left            =   -120
  29.       TabIndex        =   0
  30.       Top             =   900
  31.       Visible         =   0   'False
  32.       Width           =   90
  33.       _ExtentX        =   159
  34.       _ExtentY        =   714
  35.       _Version        =   393217
  36.       Indentation     =   353
  37.       LabelEdit       =   1
  38.       Sorted          =   -1  'True
  39.       Style           =   7
  40.       FullRowSelect   =   -1  'True
  41.       SingleSel       =   -1  'True
  42.       ImageList       =   "IMG"
  43.       Appearance      =   1
  44.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  45.          Name            =   "Euclid"
  46.          Size            =   9.75
  47.          Charset         =   0
  48.          Weight          =   400
  49.          Underline       =   0   'False
  50.          Italic          =   0   'False
  51.          Strikethrough   =   0   'False
  52.       EndProperty
  53.    End
  54.    Begin VB.CommandButton cmdExit 
  55.       Caption         =   "Exit"
  56.       Height          =   375
  57.       Left            =   6090
  58.       TabIndex        =   9
  59.       Top             =   7230
  60.       Width           =   1155
  61.    End
  62.    Begin VB.Frame fraCover 
  63.       BackColor       =   &H00685758&
  64.       BorderStyle     =   0  'None
  65.       Caption         =   "       Module Selection       "
  66.       ForeColor       =   &H0080FFFF&
  67.       Height          =   885
  68.       Left            =   30
  69.       TabIndex        =   14
  70.       Top             =   30
  71.       Width           =   9915
  72.       Begin VB.Label Label4 
  73.          Alignment       =   2  'Center
  74.          BackColor       =   &H009AD6E2&
  75.          BackStyle       =   0  'Transparent
  76.          Caption         =   "that you wish to work with then"
  77.          ForeColor       =   &H0080FFFF&
  78.          Height          =   285
  79.          Left            =   5580
  80.          TabIndex        =   17
  81.          Top             =   60
  82.          Width           =   3075
  83.       End
  84.       Begin VB.Label Label3 
  85.          Alignment       =   2  'Center
  86.          BackColor       =   &H009AD6E2&
  87.          BackStyle       =   0  'Transparent
  88.          Caption         =   "Select the Drive and Path for the VB Application"
  89.          ForeColor       =   &H0080FFFF&
  90.          Height          =   285
  91.          Left            =   570
  92.          TabIndex        =   16
  93.          Top             =   60
  94.          Width           =   4875
  95.       End
  96.       Begin VB.Label Label1 
  97.          Alignment       =   2  'Center
  98.          BackColor       =   &H009AD6E2&
  99.          BackStyle       =   0  'Transparent
  100.          Caption         =   "Check the Module(s) that you wish to View/Edit"
  101.          ForeColor       =   &H0080FFFF&
  102.          Height          =   285
  103.          Left            =   2100
  104.          TabIndex        =   15
  105.          Top             =   360
  106.          Width           =   4815
  107.       End
  108.    End
  109.    Begin VB.CommandButton cmdSave 
  110.       Caption         =   "Save"
  111.       Height          =   375
  112.       Left            =   4800
  113.       TabIndex        =   13
  114.       ToolTipText     =   "Save this module with the changes made"
  115.       Top             =   30
  116.       Width           =   1155
  117.    End
  118.    Begin VB.CommandButton cmdInsert 
  119.       Caption         =   "Insert  >"
  120.       Height          =   375
  121.       Index           =   1
  122.       Left            =   1230
  123.       TabIndex        =   12
  124.       ToolTipText     =   "Insert an INDENTED line below the selected line "
  125.       Top             =   30
  126.       Width           =   1155
  127.    End
  128.    Begin VB.CommandButton cmdDelete 
  129.       Caption         =   "Delete"
  130.       Height          =   375
  131.       Left            =   2400
  132.       TabIndex        =   11
  133.       ToolTipText     =   "Delete the selected line "
  134.       Top             =   30
  135.       Width           =   1155
  136.    End
  137.    Begin VB.CommandButton cmdInsert 
  138.       Caption         =   "Insert "
  139.       Height          =   375
  140.       Index           =   0
  141.       Left            =   60
  142.       Style           =   1  'Graphical
  143.       TabIndex        =   10
  144.       ToolTipText     =   "Insert a line below the selected line "
  145.       Top             =   30
  146.       Width           =   1155
  147.    End
  148.    Begin VB.CommandButton cmdContinue 
  149.       Caption         =   "Continue"
  150.       Height          =   375
  151.       Left            =   4860
  152.       TabIndex        =   8
  153.       Top             =   7230
  154.       Width           =   1155
  155.    End
  156.    Begin VB.CommandButton cmdOptions 
  157.       Caption         =   "Options"
  158.       Height          =   375
  159.       Left            =   3600
  160.       TabIndex        =   5
  161.       ToolTipText     =   "Change FointName Size and Colors"
  162.       Top             =   30
  163.       Width           =   1155
  164.    End
  165.    Begin MSComctlLib.ImageList IMG 
  166.       Left            =   10560
  167.       Top             =   1410
  168.       _ExtentX        =   1005
  169.       _ExtentY        =   1005
  170.       BackColor       =   -2147483643
  171.       ImageWidth      =   16
  172.       ImageHeight     =   16
  173.       MaskColor       =   12632256
  174.       UseMaskColor    =   0   'False
  175.       _Version        =   393216
  176.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  177.          NumListImages   =   9
  178.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  179.             Picture         =   "VB_Editor.frx":0000
  180.             Key             =   ""
  181.          EndProperty
  182.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  183.             Picture         =   "VB_Editor.frx":0772
  184.             Key             =   ""
  185.          EndProperty
  186.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  187.             Picture         =   "VB_Editor.frx":0BCC
  188.             Key             =   ""
  189.          EndProperty
  190.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  191.             Picture         =   "VB_Editor.frx":101E
  192.             Key             =   ""
  193.          EndProperty
  194.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  195.             Picture         =   "VB_Editor.frx":1470
  196.             Key             =   ""
  197.          EndProperty
  198.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  199.             Picture         =   "VB_Editor.frx":18C2
  200.             Key             =   ""
  201.          EndProperty
  202.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  203.             Picture         =   "VB_Editor.frx":1D14
  204.             Key             =   ""
  205.          EndProperty
  206.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  207.             Picture         =   "VB_Editor.frx":2166
  208.             Key             =   ""
  209.          EndProperty
  210.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  211.             Picture         =   "VB_Editor.frx":25B8
  212.             Key             =   ""
  213.          EndProperty
  214.       EndProperty
  215.    End
  216.    Begin VB.CheckBox chkSort 
  217.       Alignment       =   1  'Right Justify
  218.       Caption         =   "Sort Procedures"
  219.       BeginProperty Font 
  220.          Name            =   "Times New Roman"
  221.          Size            =   11.25
  222.          Charset         =   0
  223.          Weight          =   400
  224.          Underline       =   0   'False
  225.          Italic          =   0   'False
  226.          Strikethrough   =   0   'False
  227.       EndProperty
  228.       Height          =   405
  229.       Left            =   4860
  230.       TabIndex        =   18
  231.       Top             =   6690
  232.       Value           =   1  'Checked
  233.       Width           =   2385
  234.    End
  235.    Begin VB.CommandButton cmdDirty 
  236.       BackColor       =   &H80000005&
  237.       Height          =   495
  238.       Left            =   90
  239.       Style           =   1  'Graphical
  240.       TabIndex        =   19
  241.       Top             =   435
  242.       Width           =   165
  243.    End
  244.    Begin VB.TextBox txtEdit 
  245.       BeginProperty Font 
  246.          Name            =   "Euclid"
  247.          Size            =   12
  248.          Charset         =   0
  249.          Weight          =   700
  250.          Underline       =   0   'False
  251.          Italic          =   0   'False
  252.          Strikethrough   =   0   'False
  253.       EndProperty
  254.       Height          =   495
  255.       Left            =   270
  256.       MultiLine       =   -1  'True
  257.       TabIndex        =   6
  258.       Text            =   "VB_Editor.frx":2D2A
  259.       Top             =   420
  260.       Width           =   8955
  261.    End
  262.    Begin VB.DriveListBox DRV 
  263.       BeginProperty Font 
  264.          Name            =   "Times New Roman"
  265.          Size            =   9.75
  266.          Charset         =   0
  267.          Weight          =   400
  268.          Underline       =   0   'False
  269.          Italic          =   0   'False
  270.          Strikethrough   =   0   'False
  271.       EndProperty
  272.       Height          =   345
  273.       Left            =   1740
  274.       TabIndex        =   1
  275.       Top             =   1950
  276.       Width           =   2955
  277.    End
  278.    Begin VB.DirListBox DIR 
  279.       BeginProperty Font 
  280.          Name            =   "Times New Roman"
  281.          Size            =   9.75
  282.          Charset         =   0
  283.          Weight          =   400
  284.          Underline       =   0   'False
  285.          Italic          =   0   'False
  286.          Strikethrough   =   0   'False
  287.       EndProperty
  288.       Height          =   4170
  289.       Left            =   1740
  290.       TabIndex        =   2
  291.       Top             =   2370
  292.       Width           =   2955
  293.    End
  294.    Begin VB.FileListBox FLB 
  295.       BeginProperty Font 
  296.          Name            =   "Times New Roman"
  297.          Size            =   9.75
  298.          Charset         =   0
  299.          Weight          =   400
  300.          Underline       =   0   'False
  301.          Italic          =   0   'False
  302.          Strikethrough   =   0   'False
  303.       EndProperty
  304.       ForeColor       =   &H00000080&
  305.       Height          =   1215
  306.       Left            =   1830
  307.       Pattern         =   "*.frm;*.bas;*.cls;*.ctl"
  308.       TabIndex        =   4
  309.       Top             =   5280
  310.       Width           =   1935
  311.    End
  312.    Begin VB.ListBox lstChoose 
  313.       BeginProperty Font 
  314.          Name            =   "Times New Roman"
  315.          Size            =   11.25
  316.          Charset         =   0
  317.          Weight          =   700
  318.          Underline       =   0   'False
  319.          Italic          =   0   'False
  320.          Strikethrough   =   0   'False
  321.       EndProperty
  322.       Height          =   4620
  323.       ItemData        =   "VB_Editor.frx":2D30
  324.       Left            =   4860
  325.       List            =   "VB_Editor.frx":2D32
  326.       Style           =   1  'Checkbox
  327.       TabIndex        =   7
  328.       Top             =   1950
  329.       Width           =   2385
  330.    End
  331.    Begin VB.FileListBox FLB1 
  332.       BeginProperty Font 
  333.          Name            =   "Times New Roman"
  334.          Size            =   9.75
  335.          Charset         =   0
  336.          Weight          =   400
  337.          Underline       =   0   'False
  338.          Italic          =   0   'False
  339.          Strikethrough   =   0   'False
  340.       EndProperty
  341.       Height          =   540
  342.       Left            =   1740
  343.       Pattern         =   "*.vbp"
  344.       TabIndex        =   3
  345.       Top             =   3750
  346.       Width           =   2145
  347.    End
  348.    Begin VB.Label Label2 
  349.       BackColor       =   &H00685758&
  350.       Height          =   1005
  351.       Left            =   30
  352.       TabIndex        =   20
  353.       Top             =   0
  354.       Width           =   18915
  355.    End
  356. End
  357. Attribute VB_Name = "frmMain"
  358. Attribute VB_GlobalNameSpace = False
  359. Attribute VB_Creatable = False
  360. Attribute VB_PredeclaredId = True
  361. Attribute VB_Exposed = False
  362. Option Explicit
  363. Dim nKey                As Long     ' Incremented to ensure unique key
  364. Dim SubKey              As String   ' Key for modules
  365. Dim sKey                As String   ' key for root
  366. Dim selKey              As String   ' key of item selected
  367. Dim cUP                 As Boolean  ' Should next line be indented
  368. Dim cDown               As Boolean  ' should next line be outdented
  369. Dim sDek                As Boolean  ' is it a declaration line
  370. Dim bDirty              As Boolean  ' has the code on this line been edited
  371. Dim ModGot              As Boolean  ' has the Nodule been previously loaded
  372. Dim nInd                As Long     ' Index of last node selected
  373. Private Sub InitLstChoose()
  374. ' Fills a ListBox that has checkboxes with
  375. ' The mudules in the selected folder
  376. Dim N           As Long
  377.  
  378.     lstChoose.Clear
  379.     N = FLB1.ListCount
  380.     ' Get the .vbp name to use as
  381.     ' the ROOT of the treeview
  382.     If N > 0 Then
  383.         ' Only has vbp files
  384.         FLB1.ListIndex = 0
  385.         lstChoose.AddItem FLB1.FileName
  386.     Else
  387.         ' Just in case there is no .vbp in directory
  388.         lstChoose.AddItem "VB Project - Unspecified"
  389.     End If
  390.     
  391.     ' Get all the project code files
  392.     For N = 0 To FLB.ListCount - 1
  393.         ' Has all of the .frm, .bas, .cls, .ctl files
  394.         FLB.ListIndex = N
  395.         lstChoose.AddItem FLB.FileName
  396.     Next
  397. End Sub
  398. Private Sub AddRoot(S As String)
  399. Dim nodeA       As Node
  400.  
  401.     Set nodeA = TRV.Nodes.Add()
  402.     nodeA.Text = S
  403.     sKey = Chr$(nKey) & Chr$(nKey)
  404.     nodeA.Key = sKey
  405.     nodeA.Expanded = True
  406.     nodeA.Bold = True
  407.     nodeA.ForeColor = gnCol(1)
  408.     ' 1st image in the image list
  409.     nodeA.Image = 1
  410.     nKey = nKey + 1
  411. End Sub
  412. Private Sub AddModuleLevel(S As String)
  413. ' Creates a top level heading immediately
  414. ' below the ROOT for each module
  415. Dim NodeB       As Node
  416. ' The text to display on the treeview
  417. Dim sName       As String
  418.  
  419.     ' Prevent reading it more than once
  420.     If ModGot = False Then
  421.         GetModule (S)
  422.     End If
  423.     SubKey = "B" & Str(nKey)
  424.     sName = S & " - " & sR(2)
  425.     Set NodeB = TRV.Nodes.Add(sKey, tvwChild, SubKey, sName)
  426.     nKey = nKey + 1
  427.     NodeB.Bold = True
  428.     NodeB.ForeColor = gnCol(0)
  429.     NodeB.Image = 8
  430.     NodeB.Expanded = True
  431.     If chkSort.Value = 1 Then
  432.         NodeB.Sorted = True
  433.     End If
  434.     DoProcedures (S)
  435. End Sub
  436. Private Sub DoProcedures(S As String)
  437. ' Inserts all of the procedures at the next level
  438. ' Indented immediately below the Procedure name
  439. Dim N               As Long
  440. Dim Perr            As Long
  441. Dim Xerr            As Long
  442. Dim Level           As Long
  443. Dim sK(30)          As String
  444. Dim Node(30)        As Node
  445. Dim sPub            As Boolean
  446.  
  447.     Level = 3
  448.     ' Each item in the Array that contains
  449.     ' Each line to be shown on the treeview
  450.     ' Start at three so that node Index is
  451.     ' the same as the array index
  452.     For N = 3 To UBound(sR)
  453.         S = sR(N)
  454.         
  455.         ' Its a global variable
  456.         If Left$(S, 6) = "Public" Then
  457.             If Left$(S, 10) = "Public Sub" Then
  458.                 Level = 3: cUP = True
  459.             
  460.             ElseIf Left$(S, 15) = "Public Property" Then
  461.                 cUP = True
  462.             Else
  463.                 'its a Public procedure
  464.                 sPub = True
  465.             End If
  466.         ElseIf Left$(S, 11) = "Private Sub" Then
  467.             Level = 3: cUP = True
  468.         ElseIf S = "Option Explicit" Then
  469.             Level = 3: cUP = True
  470.         ElseIf S = "End Sub" Then
  471.             Level = 4
  472.         ElseIf Left$(S, 4) = "Else" Then
  473.             ' Line is to be Outdented
  474.             cDown = True
  475.             ' Next Line is to be INdented
  476.             cUP = True
  477.         Else
  478.             ' Check for start/end of nesting
  479.             NestStart (S)
  480.             NestEnd (S)
  481.             ' Check if line is a declaration
  482.             DekLares (S)
  483.         End If
  484.         
  485.         If cDown = True Then
  486.             ' Outdent 1 step
  487.             Level = Level - 1
  488.         End If
  489.         
  490.         ' Level 3 = E , 4 = F, 5 + G et.
  491.         sK(2) = SubKey
  492.         sK(Level) = Chr$(Level + 66) & Str(nKey)
  493.         If Level = 3 Then
  494.             'Node(3).Sorted = True
  495.         End If
  496.         Level = IIf(Level > 2, Level, 3)
  497.         Set Node(Level) = TRV.Nodes.Add(sK(Level - 1), tvwChild, sK(Level), sR(N))
  498.         
  499.         ' See if text contains word 'Error'
  500.         Perr = InStr(S, "Error")
  501.         Xerr = InStr(S, "Exit ")
  502.         
  503.         ' Use conditions to set Colour etc for each node
  504.         If Left$(S, 1) = "'" Then
  505.             Node(Level).ForeColor = gnCol(2)    'Remarks
  506.             Node(Level).Bold = True
  507.             Node(Level).Image = 5
  508.         ElseIf (cUP Or cDown) And Level > 3 Then
  509.              Node(Level).ForeColor = gnCol(6)   'Start or rnd of a nest
  510.         ElseIf sDek = True Then
  511.             Node(Level).ForeColor = gnCol(4)    'Declaration lines
  512.         ElseIf sPub = True Then
  513.             Node(Level).ForeColor = gnCol(3)    'Public variables
  514.         ElseIf Perr > 0 Then
  515.             Node(Level).BackColor = &H80FFFF    'Pale yellow
  516.         ElseIf Xerr > 0 Then
  517.             Node(Level).BackColor = &HC0E0FF    'Pink
  518.         ElseIf Level = 3 Then
  519.             Node(Level).ForeColor = gnCol(1)    'Procedure name
  520.         Else
  521.             Node(Level).ForeColor = gnCol(5)    'The default colour
  522.         End If
  523.             
  524.         ' Make user insertions prominent
  525.         If S = "Inserted" Then
  526.             Node(Level).ForeColor = gnCol(3)
  527.         End If
  528.             
  529.         ' Different Icon for different levels
  530.         If cUP = True Then
  531.             If Level = 3 Then
  532.                 Node(Level).Image = 3
  533.             Else
  534.                 Node(Level).Image = 2
  535.             End If
  536.             Level = Level + 1
  537.         End If
  538.         
  539.         ' Reset the booleans to false
  540.         'òò Key is Letter = Level & Index òòòòòò
  541.         nKey = nKey + 1
  542.         cDown = False
  543.         cUP = False
  544.         sDek = False
  545.         sPub = False
  546.     Next
  547. End Sub
  548. Private Sub DekLares(S As String)
  549. ' See if line is a declaration
  550. Dim M       As Long
  551. Dim x       As String
  552. Dim L       As Long
  553.  
  554.     For M = 0 To UBound(sD)
  555.         x = sD(M): L = Len(x)
  556.         If Left$(S, L) = x Then
  557.             sDek = True
  558.             Exit For
  559.         End If
  560.     Next
  561. End Sub
  562. Private Sub NestStart(S As String)
  563. ' Is it the Start of a nest
  564. ' eg  For, If, Do  etc.
  565. Dim M       As Long
  566. Dim x       As String
  567. Dim L       As Long
  568.  
  569.     For M = 0 To UBound(sT)
  570.         x = sT(M): L = Len(x)
  571.         'its start of a nest
  572.         If Left$(S, L) = x Then
  573.             'Indent NEXT line by 1 step / tab
  574.             cUP = True
  575.             Exit For
  576.         End If
  577.     Next
  578. End Sub
  579. Private Sub NestEnd(S As String)
  580. ' Is it the End of a nest
  581. Dim M       As Long
  582. Dim x       As String
  583. Dim L       As Long
  584.  
  585.     For M = 0 To UBound(sE)
  586.         x = sE(M): L = Len(x)
  587.         ' its End of a nest
  588.         If Left$(S, L) = x Then
  589.             ' Outdent 1 step
  590.             cDown = True
  591.             Exit For
  592.         End If
  593.     Next
  594. End Sub
  595. Private Sub InitTreeView()
  596. Dim N           As Long
  597. Dim S           As String
  598.  
  599.     'Looks best with aROOT
  600.     TRV.Visible = True
  601.     TRV.Nodes.Clear
  602.     For N = 0 To lstChoose.ListCount - 1
  603.         lstChoose.ListIndex = N
  604.         S = lstChoose.Text
  605.         If N = 0 Then
  606.             nKey = 1
  607.             AddRoot (S)
  608.         Else
  609.             AddModuleLevel (S)
  610.         End If
  611.     Next
  612.     ' Cannot Edit, Insert, Delete or Save
  613.     ' if loading more than 1 code module
  614.     ' So these buttons are NOT enabled
  615.     If N > 2 Then
  616.         cmdSave.Enabled = False
  617.         cmdInsert(0).Enabled = False
  618.         cmdInsert(1).Enabled = False
  619.         cmdDelete.Enabled = False
  620.     End If
  621. End Sub
  622.  
  623. Private Sub cmdContinue_Click()
  624. ' Process ONly the modules selected
  625. ' and the  Projectname
  626. '  - its the root and uses no resources
  627.  
  628. Dim N           As Long
  629. Dim L           As Long
  630.     
  631.     ' Remove the items not selected
  632.     For N = lstChoose.ListCount - 1 To 1 Step -1
  633.         If lstChoose.Selected(N) = False Then
  634.             lstChoose.RemoveItem N
  635.         End If
  636.     Next
  637.     
  638.     ' Ensure that there is a module to load
  639.     If lstChoose.ListCount < 2 Then
  640.         MsgBox "You MUST check at least ONE module"
  641.         Exit Sub
  642.     End If
  643.     
  644.     ' Uncover the Command Buttons
  645.     ' and the textbox used for editing
  646.     'fraCover.Visible = False
  647.     fraCover.Top = -1660
  648.     Me.Width = 10000
  649.     Me.Height = 10995
  650.     Me.Top = 2000
  651.     cmdExit.Top = 30
  652.     TRV.Left = 90
  653.     InitTreeView
  654. End Sub
  655.  
  656. Private Sub cmdDelete_Click()
  657.     ' Remove selected node
  658.     TRV.Nodes.Remove (nInd)
  659. End Sub
  660.  
  661. Private Sub cmdExit_Click()
  662.     Unload Me
  663. End Sub
  664. Private Sub cmdInsert_Click(Index As Integer)
  665. ' Inserts a new line below the selected line
  666. ' Imeediately below or indented 1 step
  667. Dim sInKey      As String   'Anew key for adding a line
  668. Dim NodeI       As Node
  669. Static k        As Long
  670. Dim N           As Long
  671. Dim U           As Long
  672.  
  673.     ' Some text MUST be entered Before
  674.     ' an insert can be made.
  675.     If Len(txtEdit.Text) = 0 Or bDirty = False Then
  676.         MsgBox "You MUST enter some text to Insert", _
  677.             vbInformation + vbOKOnly, "INSERT FAILED"
  678.         Exit Sub
  679.     End If
  680.     
  681.     k = k + 1
  682.     sInKey = selKey & Trim(Str(k + 10))
  683.     'sr(index) should match the text of the selected node
  684.     If sR(nInd) = TRV.Nodes.Item(nInd).Text Then
  685.         ' Index and array are synchronised
  686.         ' So it is safe to insert into array
  687.         ' and rebuild treeview
  688.         U = UBound(sR)
  689.         U = U + 1
  690.         ReDim Preserve sR(U)
  691.         For N = U To nInd + 2 Step -1
  692.             sR(N) = sR(N - 1)
  693.         Next
  694.         sR(nInd + 1) = txtEdit.Text
  695.     Else
  696.         MsgBox "Cannot Insert"
  697.         Exit Sub
  698.     End If
  699.     For N = U - 1 To 1 Step -1
  700.          TRV.Nodes.Remove (N)
  701.     Next
  702.     
  703.     ModGot = True
  704.     InitTreeView
  705.     ' Now the inserted line has to be visible
  706.     TRV.Nodes(nInd).EnsureVisible
  707.  
  708. End Sub
  709.  
  710. Private Sub cmdOptions_Click()
  711. Dim N               As Long
  712.  
  713.     frmOptions.Show vbModal
  714.     SaveOptions
  715.     ' If the colours have been changed we
  716.     ' will have to do the nodes again
  717.     If bColors = True Then
  718.         bColors = False
  719.         For N = TRV.Nodes.Count To 1 Step -1
  720.             TRV.Nodes.Remove (N)
  721.         Next
  722.         InitTreeView
  723.         ' Show the last line selected
  724.         TRV.Nodes(nInd).EnsureVisible
  725.     End If
  726. End Sub
  727.  
  728. Private Sub cmdSave_Click()
  729. ' Save the Code including any changes
  730. ' that have been made
  731. Dim fNum        As Long
  732. Dim f2Num       As Long
  733.  
  734. Dim sMName      As String
  735. Dim N           As Long
  736. Dim M           As Long
  737. Dim L           As Long
  738. Dim nD          As Node
  739. Dim S           As String
  740. Dim sL           As String
  741. Dim canStart    As Boolean
  742. Dim iNd         As Long
  743. Dim sUfx        As String
  744.  
  745.     ' Increment number to uniquely name and
  746.     ' Identify each revision to a module
  747.     nExtNum = nExtNum + 1
  748.     SaveOptions
  749.     
  750.     sUfx = Right$(sR(0), 4)
  751.     L = Len(sR(0))
  752.     sMName = Left$(sR(0), L - 4)
  753.     ' Create a unique BU name for the module
  754.     sMName = sMName & Str(nExtNum) & sUfx
  755.     ' rename mudule with unique identifier
  756.     Name VbPath & sR(0) As VbPath & sMName
  757.         
  758.     N = TRV.Nodes.Count
  759.     fNum = FreeFile
  760.     Open sMName For Input As #fNum
  761.     f2Num = FreeFile
  762.     Open VbPath & sR(0) For Output As #f2Num
  763.         'First copy original file up to Option explicit
  764.         Do Until S = "Option Explicit"
  765.             Line Input #fNum, S
  766.             If S = "Option Explicit" Then
  767.                 Exit Do
  768.             End If
  769.             Print #f2Num, S
  770.         Loop
  771.     Close #fNum
  772.     
  773.         ' save code to original filename for module
  774.         For M = 1 To N
  775.             S = TRV.Nodes(M).Text
  776.             ' Only save Code lines
  777.             If S = "Option Explicit" Then
  778.                 canStart = True
  779.             End If
  780.             If canStart = True Then
  781.                 ' Key starts with E, F, G etc
  782.                 ' Indents start with F = 4, G = 8 spaces
  783.                 sL = TRV.Nodes(M).Key & "C"
  784.                 iNd = (Asc(Left$(sL, 1)) - 69) * 4
  785.                 S = Space(iNd) & S
  786.                 Print #f2Num, S
  787.             End If
  788.         Next
  789.     Close #f2Num
  790.  
  791. End Sub
  792.  
  793. Private Sub DIR_Change()
  794.     FLB.Path = DIR.Path
  795.     ' Listbox used so that user can CHECK
  796.     ' the Modules that are required
  797.     InitLstChoose
  798.     VbPath = FLB.Path & "\"
  799. End Sub
  800.  
  801. Private Sub DIR_Click()
  802.     FLB.Path = DIR.Path
  803.     InitLstChoose
  804.     VbPath = FLB.Path & "\"
  805. End Sub
  806.  
  807. Private Sub DRV_Change()
  808.     DIR.Path = DRV.Drive
  809. End Sub
  810.  
  811. Private Sub Form_Activate()
  812.  
  813.     ' Centre the form initially
  814.     Me.Left = (Screen.Width - Me.Width) \ 2
  815.     Me.Top = (Screen.Height - Me.Height) \ 2 - 600
  816.     ' set treeview to user prefernces
  817.     TRV.Font.Name = sfName
  818.     TRV.Font.Size = nFSize
  819.     TRV.Font.Bold = bBold
  820.     Gradme
  821.     fraCover.ZOrder 0
  822. End Sub
  823.  
  824. Private Sub Form_KeyPress(KeyAscii As Integer)
  825.  
  826.     ' Purely for development to see
  827.     ' actual KeyAscii values
  828.     'Label2.Caption = Str(KeyAscii)
  829.     
  830.     'Enter key pressed and line has been changed
  831.     If KeyAscii = 13 And bDirty = True Then
  832.         ' Transfer the changes to the node
  833.         TRV.Nodes.Item(nInd).Text = txtEdit.Text
  834.         ' Keep the array the same as the nodes
  835.         sR(nInd) = txtEdit.Text
  836.         ' Make the changes prominent
  837.         TRV.Nodes.Item(nInd).ForeColor = gnCol(7)
  838.         ' Changes have been comp   
  839.         ( 4e angeslChanges have4
  840.        e 
  841.  
  842.     dEx    ( 4e anDirtund Somp   
  843.     Nty = 7Name
  844.      Buvalues
  845.        Nodes.Iter t      Nodes.Iter   Io ths.Iterrrroean
  846. Dim iN        9n
  847.     End Ix)ver.ZOcan be m
  848. ls0eReset t"e' OnIb Next
  849.     "=a)feset t"e't( N    "=a)fesesL = TR DRV.Drive
  850. End DoProcedures= 7xrive a module
  851.     nExtNum   um  Widthif      idtNd      YNd) & S
  852.            "odes.Itemeep the arm1
  853.         eB&bsures=$ueset t"e' OnIb q ch th   irue Then
  854.            Charset         =  1 ire Then
  855.    ra  sR(nInd + 1) = txtEdit.Te'e()N.)al KeyAscii values
  856.     'Label2.Caption = Str(ee9fLs
  857. Private Sub Form_Actrx  raiIndnDDu      As UF Form End If
  858.     For N = U -uDrivorm End If
  859.    
  860.     nVIf
  861.  i As  ee arm1
  862.   6    (si
  863.  i As  ee im NodeB    If
  864.    
  865.     nVIo               S = Spac5"b Next
  866.      e 
  867.  
  868.   t
  869.   ee im NodeB SpaI 2955
  870.    End
  871.    BegdnVIo òpCo055
  872.    End
  873.    Begitd DoProcedures= 7xrive a module
  874.     nExtNuimmedi N = U -uDr    D      IDCo055
  875. v Endr rnd  rnd N.)al KeyAscii v)nd) = txtEditi = U -)orm_Actistbox)el2.CaBegng
  876. Dim sL           As String
  877. Dim canStart   + Space(iNd) &sKey, tvwChild, SuMeely forH Endm   ue Then
  878.  Iil    TRC String
  879. Di
  880.         DSCo,PurelPath &e The Then
  881. ASPPath & "\"
  882. EMLa:
  883.   Iil    "
  884. eset t"e' OnIb q ch th   iNive a modultisnVIo)))Dim canStart   + SpCharset       As UF Form End If
  885.      and          =   9.75
  886.   e (S)
  887.         End If
  888.         
  889. tr(nEx=575
  890. D Space(iNd) 'a4   h   iNV_C7h= txtEdii =   9.75d + D SrBs As UFr   K3
  891. hen
  892. 3Cc_413Cc_o         
  893. AtLev4  CtLev4  CtLsa)f vSxoii = 13 ADr    D      IDCo055
  894. v End5utLev
  895. 3 gnCol(5)e1:.Height - M    ToBound(sE) save Code lines
  896.   Widthif  a"Actistneffhf  a"Actistneffhf  a"ActistnegActist5eIart oart   DegActist5eIart oart   DegActist5eIart oart  tistneffhf  a"Actistneffhf  a"ActistnegActist5eIart oar"Xy change
  897.        Ctart   Dear"Xy change
  898.        CtaeoSub
  899.  
  900. Prb5
  901.   h   xTa
  902.  
  903. PrEnd5utLevgnd5utLeLevgnd5utmodule
  904.     nExtNum   um  Widthif      k1 N = U To Scii)
  905.     Scii)
  906.   
  907.    4exrive    Chafv(ei)
  908.     Slssed and lin1tmodule
  909.  If
  910.      an'b6eEfde
  911.       Widthif      k1 N = U To Scii)
  912.     SciaCovel3