Quick Start
Quick Start
The IXF ActiveX Control control makes it extremely easy to add IXF files reading and writing capability to your applications. It takes only one statement to import/export a IXF file to your database.
First Example
The following is a demonstration of a simple application called TestIXF
Before you start following the tutorial, you need to start Visual Basic and load the IXF custom control. For help on how to load custom controls, see the Visual Basic documentation. We will use Visual Basic 6.0 but, with little differences, this tutorial is suited also for Visual Basic 5.0.
Step 1: Design the Form
Start by adding six controls to a blank form:
- Place the IXF control (Name property: IXF1) on the right area of the form.
- Place a Command Button (Name property: Command1) in the upper right corner of the form (set the Caption property to Import IXF...).
- Place a Command Button (Name property: Command2) just below Command1 (set the Caption property to Export IXF...).
- Near the right bottom of the form place a Common Dialog Box control (Name property: CommonDialog1).
- Place a Data Control (Name property: Data1) on the left area of the form. Set the Caption property to Customers, the DatabaseName property to ...\Nwind.mdb and the RecordSource property to Customers
- Place a Data Bound Grid Control (Name property: DBGrid1) on the left area of the form. Set the DataSource property to Data1 (see picture below)
Add the following code to the General Declarations section of Form1:
Dim DatabaseNameAs String
Private Sub Form_Load()
DatabaseName = App.Path + "\Nwind.mdb"
Data1.DatabaseName = DatabaseName
Data1.Refresh
End Sub
Step 2: Add code to import IXF files
This is easy. Use the Common Dialog control to choose the file and the IXF control to import it. Most of the code goes into the Command1 click event:
Private Sub Command1_Click()
With CommonDialog1
.DefaultExt = "dxf"
.DialogTitle = "Import IXF File"
.Filter = "IXF File (*.ixf)|*.ixf|All (*.*)|*.*"
.FilterIndex = 0
.Flags = &H4 Or &H2
.ShowOpen
If Len(.filename) = 0 Then Exit Sub
IXF1.Connect = ""
IXF1.DatabaseName = DatabaseName
IXF1.IXFFileName = .FileName
IXF1.ImportIXF 
Data1.RecordSource = IXF1.TableName
Data1.Caption = IXF1.TableName
Data1.Refresh
End With
End Sub
Step 3: Add code to export IXF files
Like step 2, use the Common Dialog control to choose the file and the IXF control to export a database table or query in IXF format. The code goes into the Command2 click event:
Private Sub Command2 _Click()
With CommonDialog1
.DefaultExt = "dxf"
.DialogTitle = "Import IXF File"
.Filter = "IXF File (*.ixf)|*.ixf|All (*.*)|*.*"
.FilterIndex = 0
.Flags = &H4 Or &H2
.ShowSave
If Len(.filename) = 0 Then Exit Sub
IXF1.Connect = ""
IXF1.DatabaseName = DatabaseName
IXF1.IXFFileName = .FileName
Data1.RecordSource = "SELECT CustomerID, CompanyName, ContactName, ContactTitle FROM Customers" 'This is a simple SQL query
IXF1.TableName = "Customers"
IXF1.DateCreated = Now
IXF1.ExportIXF 
End With
End Sub
Copyright © 2000/2008 Kadmos.com - All rights reserved. Privacy Policy
|