我想如果text = ""
使用contents = userval创建新文件,但是如果Len(text) > 0
那么我想查找现有文件并将其更改为此文本,如果不存在则将text和userval添加到现有内容
Public Property Let val(text,userval)
'on error resume next
Dim strText, strResult, strChange
If Len(text) >0 then
strChange = False
stream.open
stream.loadfromfile strAbsFile
strT = stream.readtext
splArr = split(strText,"^")
on error resume next
For i = 0 to Ubound(splArr)
splArrFields = split(splArr(i),"|")
If splArrFields(0) = text Then strChange = Replace(strText,splArrFields(0) & "^" & splArrFields(1),splArrFields(0) & "^" & userval) 'change value if exists
Next
If strChange Then strResult = strChange Else strResult = strT & "|" text & "^" & userval ' add text and value
stream.close
Else
strResult = userval
End If
response.write "text" & VarType(text) & " userval" & VarType(userval) & " strResult" & VarType(strResult) ' text8 userval8 strResult8
stream.open
stream.writetext mycstr(strResult)
for err11 = 0 to 50
stream.savetofile strAbsFile, 2
if Err.Number = 0 then exit for
Err.Clear
next
stream.close
End Property
但是我收到了一个错误:
错误:3001
错误(十六进制):BB9
来源:ADODB.Stream
描述:参数类型错误,超出可接受的范围,或彼此冲突。
我认为问题行是stream.savetofile strAbsFile, 2
有什么问题?