♣
数据合并问题,如何判断一个来源档是空字节数的,不给予操作接下来合并其他的来源档呢?
如果
ati040032005-06-2922000003.txt
ati040042005-06-2922000005.txt
两个来源文档的文件为空,0kb。其他来源档是有正常数据的。
现在程序如果有来源档为空的,合并数据就会报错。如果都有正常数据是可以正常数据合并的。
请问下面程序如何修改,可以即使有个别来源档为0kb,也可以正常进行数据合并呢?谢谢
invdata = datapath & "invdata" & date & "(" & left(t_time, 2) & mid(t_time, 4, 2) & ")" & ".txt"
for i = 1 to 9
if dir(datapath & "*00000" & trim(str(i)) & ".txt") <> "" then
bkdatafiles(i) = dir(datapath & "*00000" & trim(str(i)) & ".txt")
datafiles(i) = datapath & bkdatafiles(i)
set o_flst(i) = ofs.opentextfile(datafiles(i))
else
bflag(i) = true
end if
next i
for i = 10 to 11
if dir(datapath & "*0000" & trim(str(i)) & ".txt") <> "" then
bkdatafiles(i) = dir(datapath & "*0000" & trim(str(i)) & ".txt")
datafiles(i) = datapath & bkdatafiles(i)
set o_flst(i) = ofs.opentextfile(datafiles(i))
end if
next i
open mergeddata for output as #99
open invdata for output as #98
while not o_flst(1).atendofstream
tmpstring = o_flst(1).readline
policyno = left(tmpstring, 12)
ownername = mid(tmpstring, (linenumber(tmpstring, 3) + 1), (linenumber(tmpstring, 4) - linenumber(tmpstring, 3) - 1))
poldata = mid(tmpstring, (linenumber(tmpstring, 6) + 1), (linenumber(tmpstring, 7) - linenumber(tmpstring, 6) - 1))
if not finddata(policyno) then
call insertdata(policyno)
else
i = msgbox("是否还需要继续操作合并保单?", vbokcancel)
if (i = vbcancel) then
close #99
close #98
ofs.deletefile mergeddata
ofs.deletefile invdata
msgbox ("操作取消成功")
exit sub
end if
end if
print #99, "!$" & policyno
print #99, "%%prog: c:\case\cathylife\cathylife.jdt"
print #99, "gb01|" & tmpstring
if tmpstr(8) <> "" then
print #99, "gb08|" & tmpstr(8)
end if
tmpstring = o_flst(8).readline
while left(tmpstring, 12) = policyno
print #99, "gb08|" & tmpstring
if not o_flst(8).atendofstream then
tmpstring = o_flst(8).readline
else
tmpstring = ""
end if
wend
tmpstr(8) = tmpstring
if tmpstr(2) = "" then
tmpstring = o_flst(2).readline
else
tmpstring = tmpstr(2)
end if
while left(tmpstring, 12) = policyno
print #99, "gb0" & trim(str(2)) & "|" & tmpstring
if not o_flst(2).atendofstream then
tmpstring = o_flst(2).readline
else
tmpstring = ""
end if
wend
if tmpstring <> "" then
tmpstr(2) = tmpstring
end if
if bflag(3) = false then
j = 1
if tmpstr(3) <> "" then
print #99, "gb0" & trim(str(i)) & "," & tmpstr(i)
tmparry(j) = tmpstr(3)
j = j + 1
end if
tmpstring = o_flst(3).readline
while left(tmpstring, 12) = policyno
print #99, "gb0" & trim(str(i)) & "," & tmpstring
tmparry(j) = tmpstring
j = j + 1
if not o_flst(3).atendofstream then
tmpstring = o_flst(3).readline
else
tmpstring = ""
end if
wend
if not o_flst(3).atendofstream then
tmpstr(3) = ""
tmpstr(3) = tmpstring
end if
end if
for n = 1 to j - 2
for m = n + 1 to j - 1
tmparry2 = split(tmparry(n), "|")
tmparry3 = split(tmparry(m), "|")
if val(tmparry2(1)) > val(tmparry3(1)) then
tmparrystring = tmparry(n)
tmparry(n) = tmparry(m)
tmparry(m) = tmparrystring
end if
next m
next n
for n = 1 to j - 1
print #99, "gb03|" & tmparry(n)
next n
for i = 5 to 4 step -1
if bflag(i) = false then
if tmpstr(i) <> "" then
print #99, "gb0" & trim(str(i)) & "|" & tmpstr(i)
end if
tmpstring = o_flst(i).readline
while left(tmpstring, 12) = policyno
print #99, "gb0" & trim(str(i)) & "|" & tmpstring
if not o_flst(i).atendofstream then
tmpstring = o_flst(i).readline
else
tmpstring = ""
end if
wend
if tmpstring <> "" then
tmpstr(i) = tmpstring
end if
end if
next i
tmpstring = text2.text & "*." & policyno & ".*"
tmpstring = dir(tmpstring)
print #99, "gbim|" & text2.text & tmpstring
tmpstring = o_flst(11).readline
print #99, "gb11|" & tmpstring
if bflag(6) = false then
if tmpstr(6) = "" then
tmpstring = o_flst(6).readline
else
tmpstring = tmpstr(6)
end if
while left(tmpstring, 12) = policyno
print #99, "gb0" & trim(str(6)) & "|" & tmpstring
if not o_flst(6).atendofstream then
tmpstring = o_flst(6).readline
else
tmpstring = ""
end if
wend
if tmpstring <> "" then
tmpstr(6) = tmpstring
end if
end if
o_flst(10).close
set o_flst(10) = ofs.opentextfile(datafiles(10))
while not o_flst(10).atendofstream
tmpstring = o_flst(10).readline
if left(tmpstring, 12) = policyno then
print #99, "gb10|" & tmpstring
end if
wend
o_flst(7).close
set o_flst(7) = ofs.opentextfile(datafiles(7))
while not o_flst(7).atendofstream
tmpstring = o_flst(7).readline
if trim(tmpstring) <> "" then
premium = mid(tmpstring, (linenumber(tmpstring, 11) + 1), (linenumber(tmpstring, 12) - linenumber(tmpstring, 11) - 1))
if left(tmpstring, 12) = policyno then
print #99, "gb07|" & tmpstring
print #98, policyno & "|" & ownername & "|" & premium
end if
end if
wend
o_flst(9).close
set o_flst(9) = ofs.opentextfile(datafiles(9))
while not o_flst(9).atendofstream
tmpstring = o_flst(9).readline
if left(tmpstring, 12) = policyno then
print #99, "gb09|" & tmpstring
end if
wend
print #99, "%%eoj"
tmpstring = ""
for i = 1 to 11
tmpstr(i) = ""
next i
wend
close #99
close #98
for i = 1 to 11
set o_flst(i) = nothing
next i
if option1.enabled = true then
if text3.text = "" then
text3.text = "c:\case\cathylife\data\bak\"
end if
for i = 1 to 11
bkdatafiles(i) = text3.text & bkdatafiles(i)
if datafiles(i) <> "" then
if ofs.fileexists(bkdatafiles(i)) then
ofs.deletefile bkdatafiles(i)
end if
ofs.movefile datafiles(i), bkdatafiles(i)
end if
next i
else
for i = 1 to 11
if datafiles(i) <> "" then
ofs.deletefile datafiles(i)
end if
next i
end if
set ofs = nothing
msgbox ("数据文件合并完成。")
plast:
end sub
· 网友精彩回答:
dim strfile as string
for i = 1 to 9
strfile = dir(datapath & "*00000" & trim(str(i)) & ".txt")
if strfile > "" then
if filelen(strfile)then
bkdatafiles(i) = strfile
datafiles(i) = datapath & bkdatafiles(i)
set o_flst(i) = ofs.opentextfile(datafiles(i))
else
bflag(i) = true
end if
else
bflag(i) = true
end if
next i
- 更多问题:
- · 今日通宵点名(2005.7.4)
- · 群 12070268招收c java 的专家,欢迎大家来探讨!!!!
- · 群 12070268招收c java 的专家,欢迎大家来探讨!!!!
- · 请问如何将listview中的数据打印出来???
- · UDP通信,如何判断一个是否已经被其他程序占用
- · 【一万】为什么这些页面打不开呢?老家的事情,回去问问
- · 新买的机子装XP,为什么提示找不到硬盘啊。。。
- · 请问如何用group by语句分类统计?
- · 初学,请教两个小问题
- · 无线路由器配置问题
- · 请教:毕业后计算机自学的学习方法
- · 调查:有用Spring的吗? 请谈一下学习心得!
- · 清理db2log问题
- · 我如何将表中的字段自动读到combo列表中去呀?
- · 各位研究动态网页语言或者做过类似工程的大大帮我看看谢谢~【求助】
- · 请问掌握Microsoft .net容易吗?
- · vb入门
- · ftp服务器架设 | ftp
- · server专栏
- · 数据传输与加密
- · 教程中心 | 教程
- · 内存故障技术
- · oracle 中国
- · oracle 字符集
- · oracle 介绍
- · oracle select
- · sql2000
- · sql like
- · sql union
- · sql 数据类型
- · sql 游标
- · office access
- · 职业生涯设计细细规划
- · 3D Home帮您轻松玩转三维家装设计
- · 毕业设计开题报告
- · 求知 数据库课程设计“电信收费系统”的一些资料
- · photoshop9.0
- · photoshop序列号
- · 谁能告诉我photoshop7.01的序列号
- · photoshop制作
- · 火狐浏览器下载

