'Requirements: writing a text, a field value is not long enough to make the actual length of the field space, leaving a space between each field' OF: flashasp 'Created: 2005-01-18' table structure: flashasp
'==================================================== ============================================================================================================================================================================================================= ====================== 1 BZ_CODE VARCHAR 20 10 CZRQ VARCHAR 10 ZY_NUM VARCHAR 4 10 JSDH VARCHAR 20 10 Keshi Varchar 40 10 Class Varchar 1 10 Code Varchar 20 10 Unit Varchar 40 10 Kong Varchar 1 10 Num Varchar 10 10 Price VARCHAR 10 10 DEPT_NAME VARCHAR 40 10 DOCTOR VARCHAR 10 10 FSRQ VARCHAR 10 1
'==================================================== ============================================================================================================================================================================================================= ============================== "SELECT * from MiHOSPTEMP" output results
'Null 2005-01-12 2 1333 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1 Gallbladous Resection 1 280 Internal Medicine Carina 2005-01-12'Null Null Null Null Null Null Null Null 1 Thyroid Resection 1 500 Internal medicine BOY 2005-01-12 '============================================ ============================================================================================================================================================================================================= ============================== 'The following is the implementation method: ============== ============================================================================================================================================================================================================= ============================================================================================================================================================================================================= =========
Dim fnum, J, K, l_Width As IntegerDim file_name As StringDim num_fields As IntegerDim field_width () As IntegerDim field_value As StringDim i As IntegerDim num_processed As Integerfnum = FreeFilefile_name = "c: /miHospTemp.dat" Open file_name For Output As fnum Set rs = Cn.execute (SQL_Text)
Num_fields = rs.fields.count 'Writes in the actual length of field, leave a space between each field' ======================== ============================================================================================================================================================================================================= =============================================================================================================================================================================== # Then 'first writes the record of the first line, the top 5 field j = 0 k = 4 else' j = 5 k = Num_fields - 1 'Re-written the N row record after the first line, the last 9 fields end if for i = J to k field_value = rs.fields (i) .Value & "add one &" "To avoid field NULL error if i = 4 or i = k Then l_width = rs.fields (i) .definedsize 'final A field does not have spaces (ie, 4th and 14th fields) Else L_Width = rs.fields (i). DEFINEDSIZE 1 'field plus a space end if' writes text, each field A space between 1 Space Print #FNUM, LTRIM (RTRIM (Field_Value)) & _ Space (Ltrim (Ltrim (Rtrim (Rtrim (Rtrim (Rtrim (Rtrim (Rtrim (Field_Value)), VBFromunicode))); Next I Print #fnum, "" RS. MoveNext loop rsclose close fnum 'After deleting a temporary table MiHOSPTempcn.execute "delete mihosptemp"
MsgBox ("successfully exports medical insurance data, file storage path is c: /mihosptemp.dat")
Cn.closset CN = Nothing