1

I want if text = "" create new file with contents = userval, but if Len(text) > 0 then I want find existing file and change in them this text so if not exist so add text and userval to existing content.

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

But I get an error:

Error: 3001
Error (Hex): BB9
Source: ADODB.Stream
Description: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

I think problem Line is stream.savetofile strAbsFile, 2

What is wrong?

Dmitrij Holkin
  • 1,995
  • 3
  • 39
  • 86

1 Answers1

1

Try to declare Private strAbsFile in place there you set this file path