Arrays 从开始时覆盖每个的值
我正在用For-Each迭代一个集合。 每次我找到以“;”结尾的字符串时,我都需要删除该字符串。 (它用于csv解析,我有一个来自第三方的伪造文件) 当我识别一行时,我希望它用“12”覆盖现有值,例如“12;” 这段代码可以找到所有正确的行,但在ArraAccounts中没有覆盖Arrays 从开始时覆盖每个的值,arrays,asp-classic,foreach,Arrays,Asp Classic,Foreach,我正在用For-Each迭代一个集合。 每次我找到以“;”结尾的字符串时,我都需要删除该字符串。 (它用于csv解析,我有一个来自第三方的伪造文件) 当我识别一行时,我希望它用“12”覆盖现有值,例如“12;” 这段代码可以找到所有正确的行,但在ArraAccounts中没有覆盖 dim con For Each con In arrAccounts(x) if Right(con,1) = ";" then dim length length = Le
dim con
For Each con In arrAccounts(x)
if Right(con,1) = ";" then
dim length
length = Len(con)
con = Left(con, (length-1))
end if
next
我遗漏了什么/做错了什么?我认为唯一的问题是必须再次将新值插入数组
dim i, con
for i = 0 to ubound(arrAccounts(x)) ''# for keeping track which item we are looking at
con = arrAccounts(x)(i)
if right(con, 1) = ";" then
con = left(con, len(con) - 1)
arrAccounts(x)(i) = con ''# insert the new value back into the array at the same position
end if
next
我认为唯一的问题是您必须再次将新值插入数组中
dim i, con
for i = 0 to ubound(arrAccounts(x)) ''# for keeping track which item we are looking at
con = arrAccounts(x)(i)
if right(con, 1) = ";" then
con = left(con, len(con) - 1)
arrAccounts(x)(i) = con ''# insert the new value back into the array at the same position
end if
next
你说得对,我刚才就知道了。问题是写入一个局部变量而不是传入的参数。问题是写入局部变量而不是传入的参数。可以使用
output=Replace(input,;”,“”)
删除分号。可以使用output=Replace(input,;”,“”)
删除分号。