Office中国论坛/Access中国论坛
标题:
导出文本时如何去掉双引号和逗号啊[求助]
[打印本页]
作者:
盗到稻
时间:
2004-5-6 21:52
标题:
导出文本时如何去掉双引号和逗号啊[求助]
这是SQL语句
outSQL = "SELECT * INTO [Text;FMT=Delimited;HDR=Yes;DATABASE=c:\;CharacterSet=Unicode].[" & "Output.txt" & "]"
outSQL = outSQL & " FROM " & "i200404i" & ";"
输出
"000001","100001(6)"
"000002","100002(4)"
"000003","100003(2)"
"000004","100004(0)"
"000005","100005(9)"
"000006","100006(7)"
"000007","100007(5)"
请教各位高手,序列号码因为格式的需要前面的“0”应要保留。就是输出如下内容:
000001 200001(A)
000002 200002(8)
000003 200003(6)
000004 200004(4)
000005 200005(2)
000006 200006(0)
000007 200007(9)
000008 200008(7)
000009 200009(5)
作者:
zhuyiwen
时间:
2004-5-6 22:03
outSQL = "SELECT * INTO [Text;FMT=TabDelimited;HDR=Yes;DATABASE=c:\;CharacterSet=Unicode].[" & "Output.txt" & "]"
outSQL = outSQL & " FROM " & "i200404i" & ";"
这样如何?
作者:
zhuyiwen
时间:
2004-5-6 22:35
测试:
你文本文件是放在C:\下
则需要在该目录下建立一个文件:schema.ini
内容如下:
[Output.txt]
ColNameHeader=True ;表明有字段标题
CharacterSet=1200
Format=FixedLength ;表明字段输出为固定长度
Col1=A1 Char Width 10 ;第一列对应的字段名为A1, 固定宽度为10个字符
Col2=A2 Char Width 10 ;第一列对应的字段名为A1, 固定宽度为10个字符
下面是我的输出样本:
"A1","A2"
00012 abcd
00013 asdd
作者:
zhuyiwen
时间:
2004-5-6 22:41
经测试表明, 输出的格式受schema.ini文件控制
可参见Microsoft Access 帮助(OFFICE XP)
[url=mk
MSITStore:C:\Program%20Files\Common%20Files\Microsoft%20Shared\Office10\2052\jetsql40.chm::/dahowchangingtext.htm]mk
MSITStore:C:\Program%20Files\Common%20Files\Microsoft%20Shared\Office10\2052\jetsql40.chm::/dahowchangingtext.htm[/url]
[此贴子已经被作者于2004-5-6 15:30:00编辑过]
作者:
tmtony
时间:
2004-5-7 03:07
在系统表中有个隐藏表是保存有关输入输出格式的MSysIMEXColumns和 MSysIMEXSpecs两个表,可看到保存的导入导出格式。可直接对这两个表来操作,不过,需慎重
作者:
盗到稻
时间:
2004-5-7 20:09
谢谢各位,谢谢您们,偶又学了很多,因为只是输出,我最终做成这样子
Private Sub Create_Click()
Dim fs
Dim a
Dim n(7) As Integer
dblStart = Me.TextStart - 1
dblQuantity = Me.TextQuantity
lnNumber = Len(Me.TextStart)
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\Output.txt", True)
For i = 1 To dblQuantity
dblStart = dblStart + 1
strNumber = Format(i, "000000")
For j = 1 To lnNumber
n(j) = CInt(Mid(dblStart, j, 1))
Next j
kl = (324 + n(1) * 9 + n(2) * 8 + n(3) * 7 + n(4) * 6 + n(5) * 5 + n(6) * 4) Mod 11
If kl = 0 Then
chkDig = "0"
ElseIf kl = 1 Then
chkDig = "A"
Else
chkDig = CStr(11 - kl)
End If
a.WriteLine (strNumber & Space(4) & dblStart & "(" & chkDig & ")")
' a.Close
' rs1.AddNew
' rs1!Number1 = strNumber
' rs1!Serial1 = dblStart & "(" & chkDig & ")"
' rs1.Update
Next i
a.Close
End Sub
用SQL输出看来好复杂。要慢慢研究才行~~~
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3