我有一个问题,我就是想不通。我有一个电子表格,其中的数字格式化为文本,我想导入到SQL数据库中。在数据库中,数字前面有一个前导空格,取决于长度,例如“1"),”10",“100”
因此,在我的代码中,我检查了长度,然后添加了适当的空格,但是由于某种未知的原因,它似乎添加了更多的空格,但是如果我打印显示,它是正确的数量吗?
strQuery = "SELECT * FROM [Sheet1$]"
rs.Open strquery, cn
rs.MoveFirst
if rs.BOF = true and rs.EOF = true then
response.Write "Error:: Products spreadsheet is empty!"
else
while not rs.EOF
response.Write rs.Fields(0) & " " & rs.Fields(1) & "<BR><BR>"
orderno= rs.Fields(0)
lineno = rs.Fields(1)
confirmed= rs.Fields(2)
tracking= rs.Fields(3)
carrier= rs.Fields(4)
if orderno = "" or isnull(orderno) then
else
orderno = replace(orderno,"'","")
lineno = replace(lineno,"'","")
lineno = trim(lineno)
RESPONSE.WRITE("Start lengh:"&(LEN(lineno)))
if len(lineno=1) then
lineno = " "&lineno&""
end if
if len(lineno=2) then
lineno = " "&lineno&""
end if
if len(lineno=3) then
lineno = " "&lineno&""
end if
RESPONSE.WRITE("Mid lengh:"&(LEN(lineno)))
response.write("hello1"&lineno&"hello2")根据上面的代码,打印输出的起始长度是1,打印输出的中间长度是7-但我只指定添加3个空格。该值应为4个字符,前面有前导空格。任何帮助都非常感谢,真的不明白发生了什么!
发布于 2015-12-18 19:45:31
你刚刚把右括号放错地方了。
if len(lineno=1) then
应该是:
if len(lineno)=1 then
对于其他检查也是如此。
要在HTML中打印多个空格,请为所需的每个空格使用 。
https://stackoverflow.com/questions/34354252
复制相似问题