How can I convert a string array to a variant array in VBscript?

眉间皱痕 提交于 2020-01-11 09:51:31

问题


I'm using a function in vbscript which returns a variant array of strings.

JobIDs = objDoc.ConnectedSubmit(objServer)

The problem is I can't get the Job ID values from that array, as vbscript doesn't handle typed variables. It just gives a type mismatch when I attempt to do ANYTHING with the JobIDs array. I found some promising information here, but when I used the conversion function:

Set objConverter = CreateObject("ADS.ArrayConvert")
ConvertedJobIDs = objConverter.CStrArray(JobIDs())

It is giving me the same type mismatch error. Am I missing something obvious here? This is, apparently, an official microsoft solution, so I'm not sure why it seems to have the same problem, namely, not being able to actually do anything with a string array in the first place. I've seen the first part of my question answered in many places, all pointing to the MS solution, but I have yet to see any follow up reports of someone successfully using that solution.


回答1:


I'm not sure if I understand why it doesn't work, so this answer might not be very helpful. I would have thought that something like this might work (following on from your previous question I'm assuming you're trying to get the cancellation to work):

For Each id In JobIDs
    WScript.Echo id
    YourJob = YourOutgoingFaxQueue.GetJob(id)
    YourJob.Cancel()
Next


来源:https://stackoverflow.com/questions/4035513/how-can-i-convert-a-string-array-to-a-variant-array-in-vbscript

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