上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:22k
源码类别:

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{D76D7128-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "VSOCX7.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  4. Begin VB.Form Query_Frm 
  5.    BackColor       =   &H80000004&
  6.    BorderStyle     =   3  'Fixed Dialog
  7.    Caption         =   "通用查询窗体"
  8.    ClientHeight    =   7080
  9.    ClientLeft      =   3150
  10.    ClientTop       =   855
  11.    ClientWidth     =   6885
  12.    HelpContextID   =   2212015
  13.    Icon            =   "公用_查询.frx":0000
  14.    KeyPreview      =   -1  'True
  15.    LinkTopic       =   "Form5"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    MousePointer    =   4  'Icon
  19.    ScaleHeight     =   7080
  20.    ScaleWidth      =   6885
  21.    ShowInTaskbar   =   0   'False
  22.    StartUpPosition =   2  '屏幕中心
  23.    Begin MSComctlLib.ProgressBar PB_CheckStatus 
  24.       Height          =   375
  25.       Left            =   45
  26.       TabIndex        =   23
  27.       Top             =   3015
  28.       Visible         =   0   'False
  29.       Width           =   6690
  30.       _ExtentX        =   11800
  31.       _ExtentY        =   661
  32.       _Version        =   393216
  33.       Appearance      =   1
  34.       Scrolling       =   1
  35.    End
  36.    Begin VSFlex8Ctl.VSFlexGrid vsFG_Choose 
  37.       Height          =   2955
  38.       Left            =   3900
  39.       TabIndex        =   3
  40.       Top             =   360
  41.       Width           =   2895
  42.       _ExtentX        =   5106
  43.       _ExtentY        =   5212
  44.       Appearance      =   1
  45.       BorderStyle     =   1
  46.       Enabled         =   -1  'True
  47.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  48.          Name            =   "宋体"
  49.          Size            =   9
  50.          Charset         =   134
  51.          Weight          =   400
  52.          Underline       =   0   'False
  53.          Italic          =   0   'False
  54.          Strikethrough   =   0   'False
  55.       EndProperty
  56.       MousePointer    =   0
  57.       BackColor       =   -2147483643
  58.       ForeColor       =   -2147483640
  59.       BackColorFixed  =   -2147483633
  60.       ForeColorFixed  =   -2147483630
  61.       BackColorSel    =   -2147483635
  62.       ForeColorSel    =   -2147483634
  63.       BackColorBkg    =   -2147483636
  64.       BackColorAlternate=   -2147483643
  65.       GridColor       =   -2147483633
  66.       GridColorFixed  =   -2147483632
  67.       TreeColor       =   -2147483632
  68.       FloodColor      =   192
  69.       SheetBorder     =   -2147483642
  70.       FocusRect       =   1
  71.       HighLight       =   1
  72.       AllowSelection  =   -1  'True
  73.       AllowBigSelection=   -1  'True
  74.       AllowUserResizing=   0
  75.       SelectionMode   =   1
  76.       GridLines       =   1
  77.       GridLinesFixed  =   2
  78.       GridLineWidth   =   1
  79.       Rows            =   0
  80.       Cols            =   10
  81.       FixedRows       =   0
  82.       FixedCols       =   0
  83.       RowHeightMin    =   0
  84.       RowHeightMax    =   0
  85.       ColWidthMin     =   0
  86.       ColWidthMax     =   0
  87.       ExtendLastCol   =   0   'False
  88.       FormatString    =   ""
  89.       ScrollTrack     =   0   'False
  90.       ScrollBars      =   3
  91.       ScrollTips      =   0   'False
  92.       MergeCells      =   0
  93.       MergeCompare    =   0
  94.       AutoResize      =   -1  'True
  95.       AutoSizeMode    =   0
  96.       AutoSearch      =   0
  97.       MultiTotals     =   -1  'True
  98.       SubtotalPosition=   1
  99.       OutlineBar      =   0
  100.       OutlineCol      =   0
  101.       Ellipsis        =   0
  102.       ExplorerBar     =   0
  103.       PicturesOver    =   0   'False
  104.       FillStyle       =   0
  105.       RightToLeft     =   0   'False
  106.       PictureType     =   0
  107.       TabBehavior     =   0
  108.       OwnerDraw       =   0
  109.       Editable        =   0   'False
  110.       ShowComboButton =   -1  'True
  111.       WordWrap        =   0   'False
  112.       TextStyle       =   0
  113.       TextStyleFixed  =   0
  114.       OleDragMode     =   0
  115.       OleDropMode     =   0
  116.       DataMode        =   0
  117.       VirtualData     =   -1  'True
  118.    End
  119.    Begin VB.CommandButton Cmd_OK 
  120.       Caption         =   "确定(&O)"
  121.       Height          =   300
  122.       Left            =   4485
  123.       TabIndex        =   12
  124.       Top             =   6690
  125.       Width           =   1120
  126.    End
  127.    Begin MSComctlLib.TreeView TV_PreField 
  128.       Height          =   2955
  129.       Left            =   60
  130.       TabIndex        =   1
  131.       Top             =   360
  132.       Width           =   3090
  133.       _ExtentX        =   5450
  134.       _ExtentY        =   5212
  135.       _Version        =   393217
  136.       Style           =   7
  137.       Appearance      =   1
  138.    End
  139.    Begin VB.CommandButton Cmd_Remove 
  140.       Caption         =   "<"
  141.       BeginProperty Font 
  142.          Name            =   "宋体"
  143.          Size            =   10.5
  144.          Charset         =   134
  145.          Weight          =   400
  146.          Underline       =   0   'False
  147.          Italic          =   0   'False
  148.          Strikethrough   =   0   'False
  149.       EndProperty
  150.       Height          =   300
  151.       Left            =   3255
  152.       TabIndex        =   21
  153.       TabStop         =   0   'False
  154.       Top             =   915
  155.       Width           =   525
  156.    End
  157.    Begin VB.Frame Fm_Cond 
  158.       Caption         =   "条件选择"
  159.       Height          =   1140
  160.       Left            =   90
  161.       TabIndex        =   22
  162.       Top             =   3405
  163.       Width           =   6690
  164.       Begin MSComctlLib.ImageCombo ImgCmb_Field 
  165.          Height          =   315
  166.          Left            =   150
  167.          TabIndex        =   5
  168.          Top             =   345
  169.          Width           =   2505
  170.          _ExtentX        =   4419
  171.          _ExtentY        =   556
  172.          _Version        =   393216
  173.          ForeColor       =   -2147483640
  174.          BackColor       =   -2147483643
  175.       End
  176.       Begin VB.CommandButton Cmd_L 
  177.          Caption         =   "("
  178.          Height          =   300
  179.          Left            =   5434
  180.          TabIndex        =   18
  181.          TabStop         =   0   'False
  182.          Top             =   735
  183.          Width           =   500
  184.       End
  185.       Begin VB.CommandButton Cmd_R 
  186.          Caption         =   ")"
  187.          Height          =   300
  188.          Left            =   6045
  189.          TabIndex        =   19
  190.          TabStop         =   0   'False
  191.          Top             =   735
  192.          Width           =   500
  193.       End
  194.       Begin VB.CommandButton Cmd_Add 
  195.          Caption         =   "添加条件(A)"
  196.          Height          =   300
  197.          Left            =   150
  198.          TabIndex        =   14
  199.          TabStop         =   0   'False
  200.          Top             =   735
  201.          Width           =   1300
  202.       End
  203.       Begin VB.CommandButton Cmd_Clear 
  204.          Caption         =   "清除条件(L)"
  205.          Height          =   300
  206.          Left            =   1561
  207.          TabIndex        =   15
  208.          TabStop         =   0   'False
  209.          Top             =   735
  210.          Width           =   1300
  211.       End
  212.       Begin VB.CommandButton Cmd_Or 
  213.          Caption         =   "或者(H)"
  214.          Height          =   300
  215.          Left            =   4203
  216.          TabIndex        =   17
  217.          TabStop         =   0   'False
  218.          Top             =   735
  219.          Width           =   1120
  220.       End
  221.       Begin VB.CommandButton Cmd_And 
  222.          Caption         =   "并且(B)"
  223.          Height          =   300
  224.          Left            =   2972
  225.          TabIndex        =   16
  226.          TabStop         =   0   'False
  227.          Top             =   735
  228.          Width           =   1120
  229.       End
  230.       Begin MSComctlLib.ImageCombo ImgCmb_Relation 
  231.          Height          =   315
  232.          Left            =   2947
  233.          TabIndex        =   7
  234.          Top             =   345
  235.          Width           =   810
  236.          _ExtentX        =   1429
  237.          _ExtentY        =   556
  238.          _Version        =   393216
  239.          ForeColor       =   -2147483640
  240.          BackColor       =   -2147483643
  241.       End
  242.       Begin MSComctlLib.ImageCombo ImgCmb_Value 
  243.          Height          =   315
  244.          Left            =   4050
  245.          TabIndex        =   9
  246.          Top             =   345
  247.          Width           =   2505
  248.          _ExtentX        =   4419
  249.          _ExtentY        =   556
  250.          _Version        =   393216
  251.          ForeColor       =   -2147483640
  252.          BackColor       =   -2147483643
  253.       End
  254.       Begin VB.Label Lab_Note 
  255.          AutoSize        =   -1  'True
  256.          Caption         =   "项目(&M)"
  257.          Height          =   180
  258.          Index           =   2
  259.          Left            =   960
  260.          TabIndex        =   4
  261.          Top             =   150
  262.          Width           =   630
  263.       End
  264.       Begin VB.Label Lab_Note 
  265.          AutoSize        =   -1  'True
  266.          Caption         =   "关系(&R)"
  267.          Height          =   180
  268.          Index           =   3
  269.          Left            =   3105
  270.          TabIndex        =   6
  271.          Top             =   150
  272.          Width           =   630
  273.       End
  274.       Begin VB.Label Lab_Note 
  275.          AutoSize        =   -1  'True
  276.          Caption         =   "比较值(&V)"
  277.          Height          =   180
  278.          Index           =   4
  279.          Left            =   4710
  280.          TabIndex        =   8
  281.          Top             =   150
  282.          Width           =   810
  283.       End
  284.    End
  285.    Begin VB.CommandButton Cmd_Choose 
  286.       Caption         =   ">"
  287.       BeginProperty Font 
  288.          Name            =   "宋体"
  289.          Size            =   10.5
  290.          Charset         =   134
  291.          Weight          =   400
  292.          Underline       =   0   'False
  293.          Italic          =   0   'False
  294.          Strikethrough   =   0   'False
  295.       EndProperty
  296.       Height          =   300
  297.       Left            =   3255
  298.       TabIndex        =   20
  299.       TabStop         =   0   'False
  300.       Top             =   510
  301.       Width           =   525
  302.    End
  303.    Begin VB.TextBox Txt_Query 
  304.       Height          =   1800
  305.       IMEMode         =   1  'ON
  306.       Left            =   75
  307.       MultiLine       =   -1  'True
  308.       ScrollBars      =   2  'Vertical
  309.       TabIndex        =   11
  310.       Top             =   4800
  311.       Width           =   6705
  312.    End
  313.    Begin VB.CommandButton Cmd_Cancel 
  314.       Cancel          =   -1  'True
  315.       Caption         =   "取消(&C)"
  316.       Height          =   300
  317.       Left            =   5655
  318.       TabIndex        =   13
  319.       Top             =   6690
  320.       Width           =   1120
  321.    End
  322.    Begin VB.Label Lab_Note 
  323.       AutoSize        =   -1  'True
  324.       Caption         =   "待选项目(&S)"
  325.       Height          =   180
  326.       Index           =   0
  327.       Left            =   60
  328.       TabIndex        =   0
  329.       Top             =   90
  330.       Width           =   990
  331.    End
  332.    Begin VB.Label Lab_Note 
  333.       AutoSize        =   -1  'True
  334.       Caption         =   "查询项目(&X)"
  335.       Height          =   180
  336.       Index           =   1
  337.       Left            =   3900
  338.       TabIndex        =   2
  339.       Top             =   90
  340.       Width           =   990
  341.    End
  342.    Begin VB.Label Lab_Note 
  343.       AutoSize        =   -1  'True
  344.       Caption         =   "显示条件(&T)"
  345.       Height          =   180
  346.       Index           =   5
  347.       Left            =   105
  348.       TabIndex        =   10
  349.       Top             =   4575
  350.       Width           =   990
  351.    End
  352. End
  353. Attribute VB_Name = "Query_Frm"
  354. Attribute VB_GlobalNameSpace = False
  355. Attribute VB_Creatable = False
  356. Attribute VB_PredeclaredId = True
  357. Attribute VB_Exposed = False
  358. '******************************************************************
  359. '*    模 块 名 称 :查询条件
  360. '*    功 能 描 述 :
  361. '*    程序员姓名  :苗鹏
  362. '*    最后修改人  :苗鹏
  363. '*    最后修改时间:2002/01/10
  364. '*    备        注:
  365. '******************************************************************
  366. Dim cQuerys As New CQuery
  367. Dim sFieldOld As String '用以判断是否应该刷新所选字段的值
  368. Public sSqlWhere As String  '返回Where语句
  369. Public collTableName As Collection '用以返回查询条件需要的表
  370. Public bChecked As Boolean
  371. Public QueryTableSql As String
  372. Private Function InitRelation(ImgCmb As ImageCombo) '添加操作符
  373.     With ImgCmb.ComboItems
  374.         .Add , , "="
  375.         .Add , , ">"
  376.         .Add , , "<"
  377.         .Add , , "<>"
  378.         .Add , , ">="
  379.         .Add , , "<="
  380.         .Add , , "Like"
  381.     End With
  382. End Function
  383. Private Sub Cmd_Add_Click() '加入查询条件
  384.     Dim s As String
  385.     s = Me.ImgCmb_Field.Text & " " & Me.ImgCmb_Relation.Text & " " & Me.ImgCmb_Value.Text
  386.     With Me.Txt_Query
  387.         If .SelLength <> 0 Then
  388.             .Text = ReplByPos(.Text, s, .SelStart + 1, .SelStart + .SelLength + 1)
  389.         Else
  390.             .Text = .Text & " " & s
  391.         End If
  392.     End With
  393. End Sub
  394. Private Sub Cmd_And_Click() '加入And
  395.     With Me.Txt_Query
  396.         If .SelLength <> 0 Then
  397.             .Text = ReplByPos(.Text, "并且", .SelStart + 1, .SelStart + .SelLength + 1)
  398.         Else
  399.             .Text = .Text & " " & "并且"
  400.         End If
  401.     End With
  402. End Sub
  403. Private Sub Cmd_Cancel_Click() '退出
  404.     bChecked = False
  405.     sFieldOld = ""
  406.     Unload Me
  407. End Sub
  408. Private Sub Cmd_Choose_Click() '选择字段
  409.     Call TV_PreField_DblClick
  410. End Sub
  411. Private Sub Cmd_Clear_Click() '清空条件
  412.     Me.Txt_Query.Text = ""
  413. End Sub
  414. Private Sub Cmd_L_Click() '左括号
  415.     With Me.Txt_Query
  416.         If .SelLength <> 0 Then
  417.             .Text = ReplByPos(.Text, "(", .SelStart + 1, .SelStart + .SelLength + 1)
  418.         Else
  419.             .Text = .Text & " " & "("
  420.         End If
  421.     End With
  422.     
  423. End Sub
  424. Private Sub Cmd_OK_Click() '验证条件
  425.     Set cQuerys.PB_CheckStatus = Me.PB_CheckStatus
  426.     If cQuerys.CheckFormula(Me.Txt_Query) = True Then
  427.         Me.sSqlWhere = cQuerys.FormulaSys
  428.         cQuerys.GetTableName Me.collTableName
  429.         bChecked = True
  430.     Else
  431.         bChecked = False
  432.         Me.PB_CheckStatus.Visible = False
  433.         Exit Sub
  434.     End If
  435.     Me.PB_CheckStatus.Visible = False
  436.     sFieldOld = ""
  437.     Unload Me
  438. End Sub
  439. Private Sub Cmd_Or_Click() '添加或者
  440.     On Error GoTo ErrCtrl
  441.     With Me.Txt_Query
  442.         If .SelLength <> 0 Then
  443.             .Text = ReplByPos(.Text, "或者", .SelStart + 1, .SelStart + .SelLength + 1)
  444.         Else
  445.             .Text = .Text & " " & "或者"
  446.         End If
  447.     End With
  448.     Exit Sub
  449. ErrCtrl:
  450.     Dim smsg As String
  451.     Dim smsgSys As String
  452.     smsg = GetError(Err.Number)
  453.     smsgSys = Err.Number & Err.Description & "!"
  454.     MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
  455. End Sub
  456. Private Sub Cmd_R_Click() '添加右括号
  457.     On Error GoTo ErrCtrl
  458.     With Me.Txt_Query
  459.         If .SelLength <> 0 Then
  460.             .Text = ReplByPos(.Text, ")", .SelStart + 1, .SelStart + .SelLength + 1)
  461.         Else
  462.             .Text = .Text & " " & ")"
  463.         End If
  464.     End With
  465.     Exit Sub
  466. ErrCtrl:
  467.     Dim smsg As String
  468.     Dim smsgSys As String
  469.     smsg = GetError(Err.Number)
  470.     smsgSys = Err.Number & Err.Description & "!"
  471.     MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
  472. End Sub
  473. Private Sub Cmd_Remove_Click() '删除字段
  474.     Call vsFG_Choose_DblClick
  475. End Sub
  476. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) '快捷方式
  477.     If Shift = 4 Then '按住Alt
  478.         Select Case KeyCode
  479.             Case 190 '>
  480.                 Call Cmd_Choose_Click
  481.             Case 188 '<
  482.                 Call Cmd_Remove_Click
  483.             Case 57 '(
  484.                 Call Cmd_L_Click
  485.             Case 48 ')
  486.                 Call Cmd_R_Click
  487.             Case 65 'A
  488.                 Call Cmd_Add_Click
  489.             Case 66 'B
  490.                 Call Cmd_And_Click
  491.             Case 72 'H
  492.                 Call Cmd_Or_Click
  493.             Case 76 'L
  494.                 Call Cmd_Clear_Click
  495.         End Select
  496.     End If
  497.     
  498. End Sub
  499. Private Sub Form_Load()
  500.     '初始化树
  501.     Call InitView(Me.TV_PreField, QueryTableSql)
  502.     '初始化网格
  503.     InitGrid Me.vsFG_Choose
  504.     '初始化关系
  505.     InitRelation Me.ImgCmb_Relation
  506. End Sub
  507. Private Sub Form_Unload(Cancel As Integer)
  508.     Set cQuerys = Nothing
  509. End Sub
  510. Private Sub ImgCmb_Field_Click() '填充字段的可能值
  511.     With Me.ImgCmb_Field
  512.         If .SelectedItem Is Nothing Then
  513.             Exit Sub
  514.         End If
  515.         If Trim(sFieldOld) <> Trim(.SelectedItem.Key) Then
  516.             FillImgCmb .SelectedItem.Tag, Me.ImgCmb_Value
  517.             sFieldOld = .SelectedItem.Key
  518.         End If
  519.         Me.ImgCmb_Value.Text = ""
  520.     End With
  521. End Sub
  522. Private Function FillImgCmb(sTag As String, ImgCmb As ImageCombo) '填充ImgCmb,Text=Name ,Tag=Code
  523.     On Error GoTo ErrCtrl
  524.     
  525.     Dim s As String
  526.     Dim sID As String
  527.     Dim sTable As String
  528.     Dim sCode As String
  529.     Dim sName As String
  530.     Dim rs As New ADODB.Recordset
  531.     Dim Item As ComboItem
  532.     
  533.     With ImgCmb
  534.         .ComboItems.Clear
  535.         If Trim(sTag) = "" Then
  536.             Exit Function
  537.         End If
  538.         '取得帮助编码
  539.         GetFieldHelp Me.ImgCmb_Field.SelectedItem.Tag, sID, sTable, sCode, sName
  540.         '判断是否有帮助
  541.         If Trim(sID) = "0" Then
  542.             s = UCase("SELECT #sTable.#sCode AS TCode ,#sTable.#sName AS TName FROM #sTable  ")
  543.         Else
  544.             s = UCase("SELECT #sTable.#sCode AS TCode ,#sTable.#sName AS TName FROM #sTable  WHERE SortID='" & sID & "'")
  545.         End If
  546.         s = Replace(s, UCase("#sTable"), UCase(sTable))
  547.         s = Replace(s, UCase("#sCode"), UCase(sCode))
  548.         s = Replace(s, UCase("#sName"), UCase(sName))
  549.         Set rs = Cw_DataEnvi.DataConnect.Execute(s)
  550.         '如果有帮助,添加可能值
  551.         Do While Not rs.EOF()
  552.             Set Item = .ComboItems.Add(, , Trim(rs!TName & ""))
  553.             Item.Tag = Trim(rs!TCode & "")
  554.             rs.MoveNext
  555.         Loop
  556.         rs.Close
  557.     End With
  558.     Set rs = Nothing
  559.     Set Item = Nothing
  560.     Exit Function
  561. ErrCtrl:
  562.     Set rs = Nothing
  563.     Set Item = Nothing
  564.     Dim smsg As String
  565.     Dim smsgSys As String
  566.     smsg = GetError(Err.Number)
  567.     smsgSys = Err.Number & Err.Description & "!"
  568.     MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
  569. End Function
  570. Private Sub TV_PreField_BeforeLabelEdit(Cancel As Integer)
  571.     Cancel = True
  572. End Sub
  573. Private Function ChooseItem(tv As TreeView, vs As vsFlexGrid, ImgCmb As ImageCombo) '选择字段
  574.     On Error GoTo ErrCtrl
  575.     
  576.     Dim nod As Node
  577.     Dim i As Integer
  578.     Dim Item As ComboItem
  579.     Set nod = tv.SelectedItem
  580.     
  581.     If Not nod.Parent Is Nothing Then
  582.         '添加网格
  583.         i = nod.Parent.Index
  584.         With vs
  585.             .AddItem ""
  586.             .TextMatrix(.Rows - 1, 0) = nod.Parent.Key
  587.             .TextMatrix(.Rows - 1, 1) = nod.Parent.Text
  588.             .TextMatrix(.Rows - 1, 2) = nod.Key
  589.             .TextMatrix(.Rows - 1, 3) = nod.Text
  590.             .TextMatrix(.Rows - 1, 4) = nod.Tag
  591.             .TextMatrix(.Rows - 1, 5) = nod.Parent.Text & "." & nod.Text
  592.         End With
  593.         '添加下拉框
  594.         With ImgCmb
  595.             Set Item = .ComboItems.Add(, nod.Key, nod.Parent.Text & "." & nod.Text)
  596.             Item.Tag = nod.Tag
  597.         End With
  598.         '删除节点
  599.         If nod.Parent.Children = 1 Then
  600.             tv.Nodes.Remove nod.Index
  601.             tv.Nodes.Remove i
  602.         Else
  603.             tv.Nodes.Remove nod.Index
  604.         End If
  605.     End If
  606.     Set nod = Nothing
  607.     Exit Function
  608.     
  609. ErrCtrl:
  610.     Dim smsg As String
  611.     Dim smsgSys As String
  612.     smsg = GetError(Err.Number)
  613.     smsgSys = Err.Number & Err.Description & "!"
  614.     MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
  615. End Function
  616. Private Function RemoveItem(vs As vsFlexGrid, tv As TreeView, ImgCmb As ImageCombo) '删除字段
  617.     On Error GoTo ErrCtrl
  618.     
  619.     Dim nod As Node
  620.     '删除ImgCmb
  621.     With ImgCmb
  622.         .ComboItems.Remove (Trim(vs.TextMatrix(vs.Row, 2)))
  623.         .Text = ""
  624.     End With
  625.     '增加树节点
  626.     With Me.TV_PreField
  627.         
  628.         If Not IsNodeExist(Trim(vs.TextMatrix(vs.Row, 0)), Me.TV_PreField) Then
  629.             Set nod = tv.Nodes.Add("R", tvwChild, Trim(vs.TextMatrix(vs.Row, 0)), Trim(vs.TextMatrix(vs.Row, 1)))
  630.             Set nod = tv.Nodes.Add(Trim(vs.TextMatrix(vs.Row, 0)), tvwChild, Trim(vs.TextMatrix(vs.Row, 2)), Trim(vs.TextMatrix(vs.Row, 3)))
  631.             nod.Tag = Trim(vs.TextMatrix(vs.Row, 4))
  632.         Else
  633.             Set nod = tv.Nodes.Add(Trim(vs.TextMatrix(vs.Row, 0)), tvwChild, Trim(vs.TextMatrix(vs.Row, 2)), Trim(vs.TextMatrix(vs.Row, 3)))
  634.             nod.Tag = Trim(vs.TextMatrix(vs.Row, 4))
  635.         End If
  636.         '删除当前行
  637.         vs.RemoveItem (vs.Row)
  638.     End With
  639.     Exit Function
  640.     
  641. ErrCtrl:
  642.     Dim smsg As String
  643.     Dim smsgSys As String
  644.     smsg = GetError(Err.Number)
  645.     smsgSys = Err.Number & Err.Description & "!"
  646.     MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
  647. End Function
  648. Private Function InitGrid(vs As vsFlexGrid) '初始化网格
  649.     '第1列:表的物理名
  650.     '第2列:表的用户名
  651.     '第3列:字段的物理名
  652.     '第4列:字段的帮助信息
  653.     '第5列:字段的用户名
  654.     On Error GoTo ErrCtrl
  655.     
  656.     Dim i As Integer
  657.     With vs
  658.         .Cols = 6
  659.         For i = 0 To .Cols - 2
  660.             .ColHidden(i) = True
  661.         Next i
  662.         .ColWidth(.Cols - 1) = .Width - 100
  663.     End With
  664.     Exit Function
  665.     
  666. ErrCtrl:
  667.     Dim smsg As String
  668.     Dim smsgSys As String
  669.     smsg = GetError(Err.Number)
  670.     smsgSys = Err.Number & Err.Description & "!"
  671.     MsgBox IIf(smsg = "", smsgSys, smsg), vbOKOnly + vbCritical
  672. End Function
  673. Private Sub TV_PreField_DblClick()
  674.     If Me.TV_PreField.SelectedItem Is Nothing Then
  675.         Exit Sub
  676.     End If
  677.     If Me.TV_PreField.SelectedItem.Children = 0 Then
  678.         ChooseItem Me.TV_PreField, Me.vsFG_Choose, Me.ImgCmb_Field
  679.     End If
  680. End Sub
  681. Private Sub TV_PreField_KeyPress(KeyAscii As Integer)
  682.     If KeyAscii = 13 Then
  683.         Call TV_PreField_DblClick
  684.     End If
  685. End Sub
  686. Private Sub vsFG_Choose_DblClick()
  687.     If Me.vsFG_Choose.Rows > 0 Then
  688.         RemoveItem Me.vsFG_Choose, Me.TV_PreField, Me.ImgCmb_Field
  689.     End If
  690. End Sub
  691. Private Sub vsFG_Choose_KeyPress(KeyAscii As Integer)
  692.     If KeyAscii = 13 Then
  693.         Call vsFG_Choose_DblClick
  694.     End If
  695. End Sub