home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / database / dbinf / datainfo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-02-27  |  9.2 KB  |  292 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Database Informatter"
  6.    ClientHeight    =   4230
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1560
  9.    ClientWidth     =   7590
  10.    ControlBox      =   0   'False
  11.    Height          =   4635
  12.    Left            =   1035
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   4230
  16.    ScaleWidth      =   7590
  17.    Top             =   1215
  18.    Width           =   7710
  19.    Begin SSPanel Panel3D1 
  20.       BevelOuter      =   1  'Inset
  21.       Height          =   555
  22.       Index           =   4
  23.       Left            =   120
  24.       TabIndex        =   11
  25.       Top             =   120
  26.       Width           =   3615
  27.       Begin DriveListBox Drive1 
  28.          BackColor       =   &H00C0C0C0&
  29.          Height          =   315
  30.          Left            =   120
  31.          TabIndex        =   12
  32.          Top             =   120
  33.          Width           =   3375
  34.       End
  35.    End
  36.    Begin SSPanel Panel3D1 
  37.       BevelOuter      =   1  'Inset
  38.       Height          =   555
  39.       Index           =   2
  40.       Left            =   3780
  41.       TabIndex        =   10
  42.       Top             =   3540
  43.       Width           =   3675
  44.       Begin CommandButton Command3 
  45.          Caption         =   "&Help"
  46.          Height          =   315
  47.          Left            =   1320
  48.          TabIndex        =   6
  49.          Top             =   120
  50.          Width           =   1035
  51.       End
  52.       Begin CommandButton Command2 
  53.          Caption         =   "&Quit"
  54.          Height          =   315
  55.          Left            =   2520
  56.          TabIndex        =   7
  57.          Top             =   120
  58.          Width           =   1035
  59.       End
  60.       Begin CommandButton Command1 
  61.          Caption         =   "&Print"
  62.          Enabled         =   0   'False
  63.          Height          =   315
  64.          Left            =   120
  65.          TabIndex        =   5
  66.          Top             =   120
  67.          Width           =   1035
  68.       End
  69.    End
  70.    Begin SSPanel Panel3D1 
  71.       BevelOuter      =   1  'Inset
  72.       Height          =   555
  73.       Index           =   3
  74.       Left            =   120
  75.       TabIndex        =   9
  76.       Top             =   3540
  77.       Width           =   3615
  78.       Begin ComboBox Combo1 
  79.          BackColor       =   &H00C0C0C0&
  80.          Height          =   300
  81.          Left            =   120
  82.          Style           =   2  'Dropdown List
  83.          TabIndex        =   4
  84.          Top             =   120
  85.          Width           =   3375
  86.       End
  87.    End
  88.    Begin SSPanel Panel3D1 
  89.       BevelOuter      =   1  'Inset
  90.       Height          =   3375
  91.       Index           =   1
  92.       Left            =   3780
  93.       TabIndex        =   8
  94.       Top             =   120
  95.       Width           =   3675
  96.       Begin Outline Outline1 
  97.          BackColor       =   &H00C0C0C0&
  98.          Height          =   3135
  99.          Left            =   120
  100.          PictureClosed   =   DATAINFO.FRX:0000
  101.          PictureLeaf     =   DATAINFO.FRX:01A6
  102.          PictureMinus    =   DATAINFO.FRX:034C
  103.          PictureOpen     =   DATAINFO.FRX:04F2
  104.          PicturePlus     =   DATAINFO.FRX:0698
  105.          Style           =   4  'Treelines and Text
  106.          TabIndex        =   3
  107.          Top             =   120
  108.          Width           =   3435
  109.       End
  110.    End
  111.    Begin SSPanel Panel3D1 
  112.       BevelOuter      =   1  'Inset
  113.       Height          =   2775
  114.       Index           =   0
  115.       Left            =   120
  116.       TabIndex        =   0
  117.       Top             =   720
  118.       Width           =   3615
  119.       Begin FileListBox File1 
  120.          BackColor       =   &H00C0C0C0&
  121.          Height          =   2565
  122.          Left            =   1860
  123.          TabIndex        =   2
  124.          Top             =   120
  125.          Width           =   1635
  126.       End
  127.       Begin DirListBox Dir1 
  128.          BackColor       =   &H00C0C0C0&
  129.          Height          =   2505
  130.          Left            =   120
  131.          TabIndex        =   1
  132.          Top             =   120
  133.          Width           =   1695
  134.       End
  135.    End
  136. Option Explicit
  137. Dim db As database
  138. Sub Combo1_Click ()
  139.    Dim c As String
  140.    c = combo1.Text
  141.    c = Left$(c, InStr(c, ",") - 1)
  142.    file1.Pattern = c
  143.    file1.Refresh
  144. End Sub
  145. Sub Command2_Click ()
  146.    Unload form1
  147.    End
  148. End Sub
  149. Sub Command3_Click ()
  150.    Dim cMsg As String
  151.    cMsg = "DataInformatter" + Chr$(10) + Chr$(10)
  152.    cMsg = cMsg + "Yup, this is a first attempt at a VB app." + Chr$(10) + Chr$(10)
  153.    cMsg = cMsg + "If you try it, the PRINT option doesn't work.  This" + Chr$(10)
  154.    cMsg = cMsg + "is a RoundToit control, that is, _i'll get around to it_" + Chr$(10)
  155.    cMsg = cMsg + "sometime.  Also, the only selection from the file type" + Chr$(10)
  156.    cMsg = cMsg + "that works is the access/vb selection.  Again, this is another" + Chr$(10)
  157.    cMsg = cMsg + "RoundToit control." + Chr$(10) + Chr$(10)
  158.    cMsg = cMsg + "If you find it useful, have a good scotch for me," + Chr$(10)
  159.    cMsg = cMsg + "if you don't find it useful, waddya want for nothing??" + Chr$(10) + Chr$(10)
  160.    cMsg = cMsg + "I know it's sloppy, but you try and break a world record" + Chr$(10)
  161.    cMsg = cMsg + "while learning to walk. <insert emoticron of choice here>" + Chr$(10) + Chr$(10)
  162.    cMsg = cMsg + "D Roussos, 75000,720"
  163.    MsgBox cMsg
  164. End Sub
  165. Sub Dir1_Change ()
  166.    file1.Path = dir1.Path
  167. End Sub
  168. Sub Drive1_Change ()
  169.    dir1.Path = drive1.Drive
  170. End Sub
  171. Function FieldType (nFT As Integer, nDB As Integer) As String
  172. ' nFt is numeric field type
  173. ' nDB is numeric database type
  174. ' returns field typa as string
  175.    Dim c As String
  176.    c = "undefined"
  177.    Select Case nDB
  178.       Case 1   ' access/vb
  179.          Select Case nFT
  180.          Case DB_BOOLEAN
  181.             c = "boolean"
  182.          Case DB_BYTE
  183.             c = "byte"
  184.          Case DB_INTEGER
  185.             c = "integer"
  186.          Case DB_LONG
  187.             c = "long"
  188.          Case DB_CURRENCY
  189.             c = "currency"
  190.          Case DB_SINGLE
  191.             c = "single"
  192.          Case DB_DOUBLE
  193.             c = "double"
  194.          Case DB_DATE
  195.             c = "date"
  196.          Case DB_TEXT
  197.             c = "text"
  198.          Case DB_LONGBINARY
  199.             c = "binary"
  200.          Case DB_MEMO
  201.             c = "memo"
  202.          End Select
  203.       'Case 2   ' dbase
  204.    End Select
  205.    FieldType = c
  206. End Function
  207. Sub File1_DblClick ()
  208.    Dim c As String
  209.    c = dir1.Path + "\"
  210.    c = c + file1.List(file1.ListIndex)
  211.    ' fill the outline with tables and fields
  212.    FillOutline c
  213.    command1.Enabled = True
  214. End Sub
  215. Sub File1_PathChange ()
  216.    outline1.Clear
  217.    command1.Enabled = False
  218. End Sub
  219. Sub File1_PatternChange ()
  220.    outline1.Clear
  221.    command1.Enabled = False
  222. End Sub
  223. Sub FillOutline (cDB As String)
  224.    Dim n1 As Integer
  225.    Dim n3 As Integer
  226.    Dim nAttr As Long
  227.    Dim nType As Integer
  228.    Dim nSize As Integer
  229.    Dim c1 As String
  230.    Dim c2 As String
  231.    ' open db
  232.    Set db = OpenDatabase(cDB, False, True)
  233.    ' clear outline
  234.    outline1.Clear
  235.    ' add db title to outline
  236.    outline1.AddItem file1.List(file1.ListIndex), 0
  237.    ' go through list of tables
  238.    For n1 = 0 To db.TableDefs.Count - 1
  239.       ' get table name and attribs
  240.       c1 = db.TableDefs(n1).Name
  241.       nAttr = db.TableDefs(n1).Attributes
  242.       
  243.       ' if isn't system db...
  244.       If nAttr And DB_SYSTEMOBJECT Then
  245.       Else
  246.          ' then add db name to outline using -1 to place at indent 1
  247.          outline1.AddItem c1
  248.          outline1.Indent(outline1.ListCount - 1) = 1
  249.          ' set location so following additions will be at right level
  250.          outline1.AddItem "Fields"
  251.          outline1.Indent(outline1.ListCount - 1) = 2
  252.          
  253.          For n3 = 0 To db.TableDefs(n1).Fields.Count - 1
  254.             nType = db.TableDefs(n1).Fields(n3).Type
  255.             nSize = db.TableDefs(n1).Fields(n3).Size
  256.             c2 = db.TableDefs(n1).Fields(n3).Name + ", "
  257.             c2 = c2 + FieldType(nType, 1) + Str$(nSize)
  258.             outline1.AddItem c2
  259.             outline1.Indent(outline1.ListCount - 1) = 3
  260.             
  261.          Next n3
  262.       
  263.          outline1.AddItem "Indexes"
  264.          outline1.Indent(outline1.ListCount - 1) = 2
  265.          For n3 = 0 To db.TableDefs(n1).Indexes.Count - 1
  266.             c2 = db.TableDefs(n1).Indexes(n3).Name + ","
  267.             c2 = c2 + db.TableDefs(n1).Indexes(n3).Fields
  268.             outline1.AddItem c2
  269.             outline1.Indent(outline1.ListCount - 1) = 3
  270.          Next n3
  271.       End If
  272.    Next n1
  273.    db.Close
  274. End Sub
  275. Sub Form_Load ()
  276.    Dim c As String
  277.    combo1.AddItem "*.mdb, Access\VB"
  278.    combo1.AddItem "*.dbf, xBase"
  279.    combo1.AddItem "*.*, all files"
  280.    combo1.ListIndex = 0
  281.    c = combo1.List(combo1.ListIndex)
  282.    c = Left$(c, InStr(c, ",") - 1)
  283.    file1.Pattern = c
  284. End Sub
  285. Sub Outline1_DblClick ()
  286.    If outline1.Expand(outline1.ListIndex) Then
  287.       outline1.Expand(outline1.ListIndex) = False
  288.    Else
  289.       outline1.Expand(outline1.ListIndex) = True
  290.    End If
  291. End Sub
  292.