home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / db_info / datainfo.txt < prev   
Text File  |  1994-02-13  |  4KB  |  199 lines

  1. Option Explicit
  2.  
  3. Dim db As database
  4.  
  5. Sub Combo1_Click ()
  6.    Dim c As String
  7.  
  8.    c = combo1.Text
  9.    c = Left$(c, InStr(c, ",") - 1)
  10.  
  11.    file1.Pattern = c
  12.    file1.Refresh
  13.  
  14. End Sub
  15.  
  16. Sub Command2_Click ()
  17.  
  18.    Unload form1
  19.    End
  20.  
  21. End Sub
  22.  
  23. Sub Dir1_Change ()
  24.    
  25.    file1.Path = dir1.Path
  26.  
  27. End Sub
  28.  
  29. Sub Drive1_Change ()
  30.  
  31.    dir1.Path = drive1.Drive
  32.  
  33. End Sub
  34.  
  35. Function FieldType (nFT As Integer, nDB As Integer) As String
  36. ' nFt is numeric field type
  37. ' nDB is numeric database type
  38. ' returns field typa as string
  39.  
  40.    Dim c As String
  41.  
  42.    c = "undefined"
  43.  
  44.    Select Case nDB
  45.       Case 1   ' access/vb
  46.          Select Case nFT
  47.          Case DB_BOOLEAN
  48.             c = "boolean"
  49.          Case DB_BYTE
  50.             c = "byte"
  51.          Case DB_INTEGER
  52.             c = "integer"
  53.          Case DB_LONG
  54.             c = "long"
  55.          Case DB_CURRENCY
  56.             c = "currency"
  57.          Case DB_SINGLE
  58.             c = "single"
  59.          Case DB_DOUBLE
  60.             c = "double"
  61.          Case DB_DATE
  62.             c = "date"
  63.          Case DB_TEXT
  64.             c = "text"
  65.          Case DB_LONGBINARY
  66.             c = "binary"
  67.          Case DB_MEMO
  68.             c = "memo"
  69.          End Select
  70.       'Case 2   ' dbase
  71.    End Select
  72.  
  73.    FieldType = c
  74.  
  75. End Function
  76.  
  77. Sub File1_DblClick ()
  78.  
  79.    Dim c As String
  80.    
  81.    c = dir1.Path + "\"
  82.    c = c + file1.List(file1.ListIndex)
  83.    
  84.    ' fill the outline with tables and fields
  85.    FillOutline c
  86.    
  87.    command1.Enabled = True
  88.    
  89. End Sub
  90.  
  91. Sub File1_PathChange ()
  92.    
  93.    outline1.Clear
  94.    command1.Enabled = False
  95.  
  96. End Sub
  97.  
  98. Sub File1_PatternChange ()
  99.  
  100.    outline1.Clear
  101.    command1.Enabled = False
  102.  
  103. End Sub
  104.  
  105. Sub FillOutline (cDB As String)
  106.    
  107.    Dim n1 As Integer
  108.    Dim n2 As Integer
  109.    Dim n3 As Integer
  110.    Dim n4 As Integer
  111.    Dim n5 As Integer
  112.    Dim nC As Integer
  113.    
  114.    Dim nAttr As Long
  115.    Dim nType As Integer
  116.    Dim nSize As Integer
  117.    
  118.    Dim c1 As String
  119.    Dim c2 As String
  120.  
  121.    ' open db
  122.    Set db = OpenDatabase(cDB, False, True)
  123.  
  124.    ' get number of tables in db
  125.    n2 = db.TableDefs.Count
  126.    nC = 0
  127.    
  128.    ' clear outline
  129.    outline1.Clear
  130.  
  131.    ' add db title to outline
  132.    outline1.AddItem file1.List(file1.ListIndex), 0
  133.  
  134.    ' go through list of tables
  135.    For n1 = 0 To n2 - 1
  136.  
  137.       ' get table name and attribs
  138.       c1 = db.TableDefs(n1).Name
  139.       nAttr = db.TableDefs(n1).Attributes
  140.       
  141.       ' if isn't system db...
  142.       If nAttr And DB_SYSTEMOBJECT Then
  143.       Else
  144.          ' then add to outline using -1 to place at indent 1
  145.          outline1.AddItem c1, -1
  146.  
  147.          ' save location
  148.          nC = outline1.ListCount - 1
  149.  
  150.          ' set location so following additions will be at right level
  151.          outline1.ListIndex = nC
  152.  
  153.          ' get field count for table
  154.          n4 = db.TableDefs(n1).Fields.Count
  155.  
  156.          For n3 = 0 To n4 - 1
  157.             nType = db.TableDefs(n1).Fields(n3).Type
  158.             nSize = db.TableDefs(n1).Fields(n3).Size
  159.             c2 = db.TableDefs(n1).Fields(n3).Name
  160.             c2 = c2 + ", " + FieldType(nType, 1) + Str$(nSize)
  161.  
  162.             outline1.AddItem c2
  163.             
  164.          Next n3
  165.       End If
  166.    Next n1
  167.  
  168.    db.Close
  169.  
  170. End Sub
  171.  
  172. Sub Form_Load ()
  173.    
  174.    Dim c As String
  175.  
  176.    combo1.AddItem "*.mdb, Access\VB"
  177.    combo1.AddItem "*.dbf, xBase"
  178.    combo1.AddItem "*.*, all files"
  179.    combo1.ListIndex = 0
  180.  
  181.    c = combo1.List(combo1.ListIndex)
  182.    c = Left$(c, InStr(c, ",") - 1)
  183.  
  184.    file1.Pattern = c
  185.  
  186. End Sub
  187.  
  188. Sub Outline1_DblClick ()
  189.  
  190.    If outline1.Expand(outline1.ListIndex) Then
  191.       outline1.Expand(outline1.ListIndex) = False
  192.  
  193.    Else
  194.       outline1.Expand(outline1.ListIndex) = True
  195.  
  196.    End If
  197. End Sub
  198.  
  199.