Declare Function z1Init_Dbf Lib "z1_Dbf.dll" () As Integer
Declare Function z1Add_Dbf_Field Lib "z1_Dbf.dll" (ByVal hDbf As Integer, ByVal cFieldname As String, ByVal cType As String, ByVal length As Integer, ByVal dec As Integer) As Integer
Declare Function z1Create_Dbf Lib "z1_Dbf.dll" (ByVal hDbf As Integer, ByVal cFilename As String) As Integer
Sub Command1_Click ()
Dim i As Integer
Dim hDbf As Integer
Dim cName As String
Dim cType As String
Dim nLength As Integer
Dim nDec As Integer
Dim x As Integer
' create the dbf now
If ctrFilename = "" Then
MsgBox "Invalid filename!", 16, "Error"
Exit Sub
End If
hDbf = z1Init_Dbf()
If hDbf = 0 Then
MsgBox "Unable to initialise Z1_DBF.DLL", 16, "Error"
Exit Sub
End If
' go to the end of the list so we can then go back to the top
lstFields.ListIndex = lstFields.ListCount - 1
For i = 0 To lstFields.ListCount - 1
' set position is the same as click
lstFields.ListIndex = i
' we should now have the fields setup correctly
cName = ctrFieldName
If rdbType(0) Then
cType = "C"
ElseIf rdbType(1) Then
cType = "D"
ElseIf rdbType(2) Then
cType = "N"
ElseIf rdbType(3) Then
cType = "L"
ElseIf rdbType(4) Then
cType = "M"
End If
nLength = Val(ctrLength)
nDec = Val(ctrDec)
If z1Add_Dbf_Field(hDbf, cName, cType, nLength, nDec) = 0 Then