Microsoft VBScript运行时错误' 800a0005'无效的程序调用或参数:' mid'

时间:2016-07-25 08:23:50

标签: vbscript runtime

我在申请中遇到了一个错误

的问题
  

Microsoft VBScript运行时错误' 800a0005'
  无效的程序调用或参数:' mid'
  strLine = Trim(Mid(strLine,1,InStr(UCase(strLine)," SINGLE POINT DATA") - 1))

主要功能如下

strLine = tstextstreamRead.ReadAll

If cint(intTestId) = 23 Then
    strLine2 = Trim(Mid(strLine, InStr(UCase(strLine), "SINGLE POINT DATA") + 1, Len(strLine)))
    strLine2 = Trim(Mid(strLine2, InStr(strLine2, "Model Cross-Arrhenius"), Len(strLine2)))
End If
response.write strLine

strLine = Trim(Mid(strLine, 1, InStr(UCase(strLine), "SINGLE POINT DATA") - 1))

当我通过response.write strline验证时

下面我得到了数据

Sample ID Region :PACIFIC 
Request No :tesy 
Sample No :12 
Company :213 
Family :213 
Grade :213 
Standard :ZOLLER METHOD 
Color No :UNKNOWN 
Lot No :UNKNOWN 
Remark :213 
Date :7/22/2016 
Generic :123 
Operator :213 
Test Lab :WTC 
Test Name :Pressure-Volume-Temperature (PVT) 
Test Method :ZOLLER METHOD 
Dataset 0 
POINTS 26 30.2 1109.998 40.6 1126.961 50.8 1124.916 61.1 1121.716 71.3 1117.909 81.5 1113.674 91.4 1108.76 101.4 1103.019 111.8 1095.211 121.8 1087.404 131.8 1079.681 142.2 1072.674 152 1065.485 162.3 1057.771 172.1 1050.805 182.3 1043.491 193.4 1036.327 203 1029.239 214.1 1022.532 223.6 1015.535 234.6 1008.179 245.1 1000.297 255 993.677 265.6 986.178 275.4 979.918 285.8 973.305 
Dataset 50 
POINTS 26 30.2 1141.188 40.6 1145.201 50.8 1142.895 61.1 1140.183 71.3 1137.529 81.5 1134.817 91.4 1132.018 101.4 1129.33 111.8 1125.39 121.8 1120.212 131.8 1113.709 142.2 1107.681 152 1101.57 162.3 1095.298 172.1 1089.361 182.3 1083.419 193.4 1077.757 203 1072.34 214.1 1066.657 223.6 1061.414 234.6 1055.779 245.1 1049.333 255 1043.651 265.6 1038.333 275.4 1033.283 285.8 1028.57 
Dataset 100 
POINTS 26 30.2 1160.699 40.6 1159.695 50.8 1157.533 61.1 1155.299 71.3 1153.075 81.5 1151.028 91.4 1149.093 101.4 1147.7 111.8 1145.902 121.8 1142.99 131.8 1138.733 142.2 1133.957 152 1128.643 162.3 1123.009 172.1 1117.834 182.3 1112.526 193.4 1107.26 203 1102.65 214.1 1097.619 223.6 1093.004 234.6 1086.949 245.1 1082.376 255 1077.455 265.6 1072.812 275.4 1068.752 285.8 1064.607 
Dataset 150 
POINTS 26 30.2 1174.42 40.6 1172.732 50.8 1170.673 61.1 1168.593 71.3 1166.813 81.5 1165.074 91.4 1163.543 101.4 1162.673 111.8 1161.681 121.8 1160.11 131.8 1157.741 142.2 1154.905 152 1150.866 162.3 1146.22 172.1 1141.382 182.3 1136.381 193.4 1131.774 203 1127.484 214.1 1123.175 223.6 1118.773 234.6 1113.149 245.1 1108.975 255 1104.514 265.6 1100.457 275.4 1096.706 285.8 1093.423 
Dataset 200 
POINTS 26 30.2 1185.837 40.6 1183.95 50.8 1182.17 61.1 1180.377 71.3 1178.593 81.5 1177.103 91.4 1175.963 101.4 1175.373 111.8 1174.678 121.8 1173.552 131.8 1172.182 142.2 1170.538 152 1168.029 162.3 1164.802 172.1 1160.855 182.3 1156.361 193.4 1152.075 203 1147.987 214.1 1143.934 223.6 1139.92 234.6 1134.884 245.1 1130.755 255 1126.75 265.6 1123.348 275.4 1119.874 285.8 1116.635

请告诉我究竟是什么问题。

1 个答案:

答案 0 :(得分:2)

您的数据不包含"单点数据",因此InStr()返回0(未找到),您的Mid()调用归结为

>> s = Mid("s", 1, -1)
>>
Error Number:       5
Error Description:  Invalid procedure call or argument
>>

您应该检查Instr()结果:

nPos = InStr(UCase(strLine), "SINGLE POINT DATA")
If 0 = nPos Then
   WScript.Echo "Bingo"
Else
   strLine = Trim(Mid(strLine, 1, nPos - 1))
End If