vbscript中无效的过程调用或参数 [英] Invalid procedure call or argument in vbscript

查看:235
本文介绍了vbscript中无效的过程调用或参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vb脚本将文件上传到服务器.我遇到的问题是,当我将文件设置为ASCII格式时...

Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)

调用子提示

时出现错误

无效的过程调用或参数

但是如果我将文件设置为unicode

Set oFile = oFS.CreateTextFile(sPath & FileName, True, True)

它成功上传,但由于编码错误而无法打开. 如果格式为ASCII,则产生错误的行就是这一行

oFile.Write BinaryToString(FileData)

其中oFile是我在上面创建的ASCII文件

这是产生错误的源代码.这是我上网的上传功能.

Public Sub SaveToDisk(sPath)
        Dim oFS, oFile
        Dim nIndex

        If sPath = "" Or FileName = "" Then Exit Sub
        If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"

        Set oFS = Server.CreateObject("Scripting.FileSystemObject")
        If Not oFS.FolderExists(sPath) Then Exit Sub

        Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
        oFile.Write BinaryToString(FileData)

        oFile.Close
    End Sub

    Function BinaryToString(Binary)
        'Antonin Foller, http://www.motobit.com
        'Optimized version of a simple BinaryToString algorithm.

        Dim cl1, cl2, cl3, pl1, pl2, pl3
        Dim L
        cl1 = 1
        cl2 = 1
        cl3 = 1
        L = LenB(Binary)

        Do While cl1<=L
            pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
            cl1 = cl1 + 1
            cl3 = cl3 + 1
            If cl3>300 Then
                pl2 = pl2 & pl3
                pl3 = ""
                cl3 = 1
                cl2 = cl2 + 1
                If cl2>200 Then
                    pl1 = pl1 & pl2
                    pl2 = ""
                    cl2 = 1
                End If
            End If
        Loop
        BinaryToString = pl1 & pl2 & pl3
    End Function

可以在服务器上进行配置吗?如果这有任何意义,请提供帮助.

解决方案

我怀疑BinaryToString不仅会返回ASCII字符(实际上是当前OEM代码页),而且还会返回Unicode范围内OEM代码页集以外的其他字符.

BinaryToString到底做什么?

I am using vb script to upload a file to the server. The problem I'm having is that when I set the file to ASCII format like this...

Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)

I get an error when the sub is called that says

Invalid procedure call or argument

but if I set the file to unicode

Set oFile = oFS.CreateTextFile(sPath & FileName, True, True)

it uploads successfully but will not open because of the incorrect encoding. The line that produces the error is this one if format is ASCII is this one

oFile.Write BinaryToString(FileData)

where oFile is the ASCII file I had created above

Here is the source code that produces the error. It's an upload function I got off the net..

Public Sub SaveToDisk(sPath)
        Dim oFS, oFile
        Dim nIndex

        If sPath = "" Or FileName = "" Then Exit Sub
        If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"

        Set oFS = Server.CreateObject("Scripting.FileSystemObject")
        If Not oFS.FolderExists(sPath) Then Exit Sub

        Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
        oFile.Write BinaryToString(FileData)

        oFile.Close
    End Sub

    Function BinaryToString(Binary)
        'Antonin Foller, http://www.motobit.com
        'Optimized version of a simple BinaryToString algorithm.

        Dim cl1, cl2, cl3, pl1, pl2, pl3
        Dim L
        cl1 = 1
        cl2 = 1
        cl3 = 1
        L = LenB(Binary)

        Do While cl1<=L
            pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
            cl1 = cl1 + 1
            cl3 = cl3 + 1
            If cl3>300 Then
                pl2 = pl2 & pl3
                pl3 = ""
                cl3 = 1
                cl2 = cl2 + 1
                If cl2>200 Then
                    pl1 = pl1 & pl2
                    pl2 = ""
                    cl2 = 1
                End If
            End If
        Loop
        BinaryToString = pl1 & pl2 & pl3
    End Function

Could it be configurations on the server? If this makes any sense please help..

解决方案

I suspect BinaryToString returns not only ASCII (actually the current OEM codepage) characters but also other characters in the unicode range that are outside the OEM codepage set.

What exactly does BinaryToString do?

这篇关于vbscript中无效的过程调用或参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆