Sub Exit_Click
  'close forms and exit
  bye
End Sub

Sub ShowFA_Click
  Dim flist
  
  'Connect to the database
  Set conndb = CreateObject("ADOCE.Connection.3.1")
  conndb.ConnectionString = "Data Source = " & eb1.text
  '\My Documents\BCS Client V2-3d.cdb"
  conndb.Open

  'Select a recordset
  Set rs = CreateObject("ADOCE.RecordSet.3.1")
  rs.Open cb1.text, conndb, 1, 1

  cb2.clear
  maxcol=rs.fields.count-1
  For i=0 to maxcol
    cb2.additem rs.Fields(i).name
  Next

  memo.text = ""
  If rs.RecordCount > 0 Then
    Do While Not rs.EOF
      flist = ""
      For i=0 to maxcol
        If (flist="") Then
          flist = rs.fields(i).value
        Else
          flist = flist & "#" & rs.fields(i).value
        End If
      Next
      memo.text = memo.text & chr(13) & chr(10) & flist
      rs.MoveNext
    Loop
  End If
  
  If (Not (cb2.ListCount = 0)) Then
    cb2.ListIndex = 0
  End If
  
  rs.Close
  Set rs = Nothing
  conndb.Close
  Set conndb = Nothing
End Sub

Sub ShowTA_Click
  'Connect to the database
  Set conndb = CreateObject("ADOCE.Connection.3.1")
  conndb.ConnectionString = "Data Source = " & eb1.text
  '\My Documents\BCS Client V2-3d.cdb"
  conndb.Open

  'Select a recordset
  Set rs = CreateObject("ADOCE.RecordSet.3.1")
'  rs.Open "msystables", conndb, adOpenKeySet, adLockOptimistic
  rs.Open "msystables", conndb, 1, 1

  'alt flags for open : adOpenForwardOnly, adLockReadOnly
  If rs.RecordCount > 0 Then
    Do While Not rs.EOF
      cb1.AddItem rs.Fields("TableName").Value
      rs.MoveNext
    Loop
  End If

  If (Not (cb1.ListCount = 0)) Then
    cb1.ListIndex = 0
  End If
  
  rs.Close
  Set rs = Nothing
  conndb.Close
  Set conndb = Nothing
End Sub

Sub test_Click
  'PBox.DrawText "This is a test mesaage"
  Output.DrawText "This is a test mesaage"
End Sub

Sub Form1_Load
  'AddObject "Picturebox", "PBox",0,0,240,260
  'PBox.BorderStyle = 1
  AddObject "label", "lb1",5,5,40,20
  lb1.backcolor = &H00C0C0C0
  lb1.caption = "DBase"
  AddObject "textbox","eb1",50,5,185,20
  eb1.borderstyle = 1
  eb1.maxlength = 80
  eb1.text = "\My Documents\BCS Client V2-3d.cdb"
  
  AddObject "label", "lb2",5,30,40,20
  lb2.caption = "Tables"
  lb2.backcolor = &H00C0C0C0
  AddObject "ComboBox", "cb1", 50, 30, 185, 200
  cb1.Style = 2

  AddObject "label", "lb3",5,55,40,20
  lb3.caption = "Fields"
  lb3.backcolor = &H00C0C0C0
  AddObject "ComboBox", "cb2", 50, 55, 185, 200
  cb2.Style = 2

  AddObject "textbox","memo",0,80,240,190
  memo.borderstyle = 1
  memo.scrollbars = 3
  memo.multiline = True
End Sub
