2

我在 UFT/QTP 14.00 中有这个问题。我想使用函数中的属性来编写日志文件,但在运行操作时返回此错误。

错误信息:对象不支持属性或方法

这是我的代码:

Function Escrito
    'Function in VBS
    'Habilitamos la creacion y modificacion de archivos
        'Enable Create and update files
     Set fso=createobject("Scripting.FileSystemObject")
     set Stream = fso.CreateTextFile("C:\Users\HCCMD\Documents\test.txt")
     Escrito = Stream
End Function

我想使用Escrito().write "Hola mundo"例如。

4

1 回答 1

3

你忘了Set

Set Stream = fso.CreateTextFile("C:\Users\HCCMD\Documents\test.txt")
Set Escrito = Stream

或者,更简单

Set Escrito = fso.CreateTextFile("C:\Users\HCCMD\Documents\test.txt")

另请参阅:关键字 Set 在 VBA 中的实际作用是什么?(也适用于 VBScript)

于 2018-07-03T20:28:32.597 回答