why vbscript Mid function shows error 'Invalid Procedure Call or argument : Mid'

假装没事ソ 提交于 2019-12-13 14:21:12

问题


Hi Below is my code of ASPClassic, in which csvData is a very large string containing variable.Now in this At line where Mid function is call error 'Invalid Procedure Call or argument : Mid' occur why this happens...

Dim dataLen 
    Dim fromLen 
       Dim toLen 
       Dim slab 
       Dim totalPass 

       dataLen =len(csvData)
       fromLen =0
       toLen =100000
       slab =100000
       totalPass =(dataLen/slab)
    if (dataLen Mod slab)>0  then
        totalPass=totalPass+1
    end if
    Dim i
    For i = 0 To dataLen
        i=toLen
        if toLen > dataLen then
            toLen=dataLen
        end if 
       Response.Write Mid(csvData,fromLen,toLen)
        fromLen=toLen
        toLen=toLen+slab
    Next

回答1:


I think that your fromLen is 0, when you call Mid() for the first time:

>> m = Mid("x", 0, 1)
>>
Error Number:       5
Error Description:  Invalid procedure call or argument

Try to initialize with:

fromLen = 1



回答2:


mid start position can not be 0 it should always be from 1



来源:https://stackoverflow.com/questions/13970723/why-vbscript-mid-function-shows-error-invalid-procedure-call-or-argument-mid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!