09/10/2018, 17:25
cap cuu, cap cuu
Đoạn code sau đây không thể chạy được vì nhận lỗi
Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument
/vbasp/uploader.asp, line 80 <-- dòng 80 tương ứng với dòng file.Write chr(ascb(midb(temp,tpoint,1)))
Nhưng chỉ cần thay tpoint trong chr(ascb(midb(temp,tpoint,1))) bằng một giá trị số (thậm chí là dùng một biến khác và thiết lập cố định giá trị đó trước) trong khoảng 1 –> LenB (temp) thì nó lại chạy bình thường.
Vậy lỗi trên ở đâu ra??????
Public Function saveToFile(name, path)
Dim tPoint
If dict.Exists(name) Then
Dim temp
temp = dict(name).Item("Value")
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile(path)
For tPoint = 1 to LenB(temp)
file.Write chr(ascb(midb(temp,tpoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function
Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument
/vbasp/uploader.asp, line 80 <-- dòng 80 tương ứng với dòng file.Write chr(ascb(midb(temp,tpoint,1)))
Nhưng chỉ cần thay tpoint trong chr(ascb(midb(temp,tpoint,1))) bằng một giá trị số (thậm chí là dùng một biến khác và thiết lập cố định giá trị đó trước) trong khoảng 1 –> LenB (temp) thì nó lại chạy bình thường.
Vậy lỗi trên ở đâu ra??????
Public Function saveToFile(name, path)
Dim tPoint
If dict.Exists(name) Then
Dim temp
temp = dict(name).Item("Value")
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile(path)
For tPoint = 1 to LenB(temp)
file.Write chr(ascb(midb(temp,tpoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function
Bài liên quan
temp = dict(name).Item("Value")
Hãy xem lại giá trị của temp lúc đó.
Bạn đã kiểm tra:......If dict.Exists(name) Then ...
Nhưng sau đó lại là:.........temp = dict(name).Item("Value") .......
Cấu trúc dictionary object của bạn ra sao?
Hãy trình bày lại phần đó.
mình tìm ra lỗi rồi. Tại thiết lập Codepage nên nó mới bị vậy. Sau khi remove đi thì bình thường