原来是每人2科,现在为每人3科。在你的代码基础上照样画剽,改动了下:
Create table T (准考证号 C(12),姓名 C(8),性别 C(2),报名点 C(20),班级 C(20),考试科目1 C(10),考点1 C(20),考场1 C(4),坐位1 C(6),考试科目2 C(10),考点2 C(20),考场2 C(4),坐位2 C(6),考试科目3 C(10),考点3 C(20),考场3 C(4),坐位3 C(6))
cStr=Strconv(Filetostr("1.txt"),6)
I=0
For lnI=1 To Alines(Ab,cStr,Chr(13)+Chr(10))
Do case
Case "准考证号"$Ab[lnI]
I=I+1
=Alines(A1,Ab[lnI],"准考证号")
Zkzh1=A1[2]
Zkzh2=A1[3]
Case "性别"$Ab[lnI]
I=I+1
=Alines(A2,Ab[lnI],"姓 名","性别")
Xm1=A2[2]
Xm2=A2[4]
Xb1=A2[3]
Xb2=A2[5]
Case "报名点"$Ab[lnI]
I=I+1
=Alines(A3,Ab[lnI],"报名点")
Bmd1=A3[2]
Bmd2=A3[3]
Case "班 级"$Ab[lnI]
I=I+1
=Alines(A4,Ab[lnI],"班 级")
Bj1=A4[2]
Bj2=A4[3]
Case "历史"$Ab[lnI]
I=I+1
Kskm1="历史"
=Alines(A5,Ab[lnI],Kskm1)
Kdmc1=Chrtran(A5[2],"0123456789","")
Kc1=Strtran(A5[2],Kdmc1,"")
Kdmc2=Chrtran(A5[3],"0123456789","")
Kc2=Strtran(A5[3],Kdmc2,"")
Zw1=Left(Ab[lnI+1],6)
Zw2=Right(Ab[lnI+1],6)
lnI=lnI+1
Case "地理"$Ab[lnI]
I=I+1
Kskm2="地理"
=Alines(A6,Ab[lnI],Kskm2)
Kdmc11=Chrtran(A6[2],"0123456789","")
Kc11=Strtran(A6[2],Kdmc11,"")
Kdmc21=Chrtran(A6[3],"0123456789","")
Kc21=Strtran(A6[3],Kdmc21,"")
Zw11=Left(Ab[lnI+1],6)
Zw21=Right(Ab[lnI+1],6)
lnI=lnI+1
Case "化学"$Ab[lnI]
I=I+1
Kskm3="化学"
=Alines(A7,Ab[lnI],Kskm3)
Kdmc31=Chrtran(A7[2],"0123456789","")
Kc31=Strtran(A7[2],Kdmc31,"")
Kdmc32=Chrtran(A7[3],"0123456789","")
Kc32=Strtran(A7[3],Kdmc32,"")
Zw31=Left(Ab[lnI+1],6)
Zw32=Right(Ab[lnI+1],6)
lnI=lnI+1
Endcase
If I=6
I=0
Insert Into T Values (Zkzh1,Xm1,Xb1,Bmd1,Bj1,Kskm1,Kdmc1,Kc1,Zw1,Kskm2,Kdmc11,Kc11,Zw11,kskm3,kdmc31,kc31,zw31) 运行到此句提示:找不到为量kskm3.前面不是有kskm3="化学",为什么会找不到?
Insert Into T Values (Zkzh2,Xm2,Xb2,Bmd2,Bj2,Kskm1,Kdmc2,Kc2,Zw2,Kskm2,Kdmc21,Kc21,Zw21,kskm3,kdmc32,kc32,zw32)
Endif
Endfor
Browse