调用子vb时不能使用括号

-1 vbscript parentheses

首先,我已经看过网站上的类似问题,但无法发现我的方式错误.

我也是vb的新手,所以这也没有帮助.

请帮助一个真正的新手......

谢谢

dim profileSize
dim oFS, oFolder
set oFS = WScript.CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
set oFolder = oFS.GetFolder("\\burns\Profiles\" + strUserName + ".V2")

ShowFolderDetails oFolder

sub ShowFolderDetails(oF)
dim F
    profileSize = of.Size
    if profileSize > 1006582400 Then    
    WriteFileText(profileSize, strUserName)
    End If
    if profileSize > 2516582400 Then    
    WriteFileText(profileSize, strUserName)
    wscript.echo "Your Windows user profile is too big! Please contact the IT Office"
    WScript.Quit
    End if

    for each F in oF.Subfolders
    'ShowFolderDetails(F)
    next
end sub


sub WriteFileText(sText, userID)
    Dim objFSO 'As FileSystemObject
    Dim objTextFile 'As Object
    strLogFilePath = "\\burns\Profiles\size_log.txt"
    strTime = FormatDateTime(Date(), 0)
    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile(strLogFilePath, ForAppending, True)

    ' Write a line.
    objTextFile.WriteLine (strTime + "," + userID + "," + sText )

    objTextFile.Close
    'objTextFile.Close

End Sub
Run Code Online (Sandbox Code Playgroud)

Sto*_*kke 5

错误消息"调用Sub时不能使用括号"表示在调用sub时不能使用括号;-).

在VBA中,如果符合以下条件,则使用括号进行函数调用:

  1. 函数调用具有对返回值的赋值.
  2. 你有一个参数列表并使用'call'关键字.

所以你应该可以这样调用你的子:

WriteFileText x,y
Run Code Online (Sandbox Code Playgroud)

或者,如果你坚持括号:

call WriteFileText (x, y) 
Run Code Online (Sandbox Code Playgroud)

  • 有关详细信息,请参阅[此处](http://blogs.msdn.com/b/ericlippert/archive/2003/09/15/52996.aspx). (2认同)