假设我有一个数组A1(6)=(45,25,,36,88),A2(6)=(14,25,11),A3(6)=(11,21,20,25,48)现在,我们可以借助单个语句(如单个数组赋值)将这些数组值放到一行中,就像这里所有行到Excel的范围一样,在这里说"C1:R3"范围.
Dim R
R = Split(Join(A1, ",") & "," & Join(A2, ",") & "," & Join(A3, ","), ",")
Range("C5:T5").Value = R
Run Code Online (Sandbox Code Playgroud)
现在我们可以将字典项(它是一个数组)组合成一维数组并分配回一个范围吗?
For Each ChilID In ChildIDs
Redim ChildDetailArray(ArrIndex)
ChildMatchNum=objExcel1.Application.WorksheetFunction.Match(ChilID, ob3.Columns(1), 0)
ChildDetailArray=ob1.Range(ob1.Cells(ChildMatchNum,1),ob1.Cells(ChildMatchNum,ArrIndex+1)).Value
ChildDic.Add ChilID,ChildDetailArray '(ChildDetailArray is an array)
Next
Run Code Online (Sandbox Code Playgroud)
EDIT1
suppose a process#20 has 2 child processes say #12,#13. now i used a dictionary object Dic
Dic(12)=Arr(10,11,,,18) 'child details
Dic(13)=Arr(5,8,9,,,) ' child details
***Output:*** `1D array say ArrMerger()=(10,11,,,18,5,8,9,,,)`
Run Code Online (Sandbox Code Playgroud)
以上For Loop是做同样的事情.现在Loop将完成,我希望那些作为Dic(12)和Dic(13)的项目的子细节需要在一维数组中收集
UPDATE
strJoin = ","
For …Run Code Online (Sandbox Code Playgroud) 码
height = objExcel1.Application.WorksheetFunction.CountA(ob3.Columns(1))
'MsgBox(height)
ReDim dataArray(height - 2, 0) ' -1 for 0 index, -1 for the first row as header row, excluded
str = ""
dataArray = ob3.Range(ob3.Cells(2, 1),ob3.Cells(height, 1)).Value
Set d = CreateObject("scripting.dictionary")
'MsgBox(LBound(DeletArr) & ":" & UBound(DeletArr))
For i = LBound(DeletArr) To UBound(DeletArr)
If Not d.exists(DeletArr(i)) Then
d(DeletArr(i)) = 0
End If
Next
MsgBox(LBound(dataArray,1) & ":" & UBound(dataArray,1))
For i = LBound(dataArray, 1) To UBound(dataArray, 1) - 1
If d.exists(dataArray(i, 1)) Then
str = str & …Run Code Online (Sandbox Code Playgroud) 我有一个数组说:VMHArray=(12,22,34,4)现在有另一个Arraylist对象说ArrayListTaskDetails将数据保存为(12,55,44,4,12,22,21,107,43,22,34)现在下面的代码我写信从列表中删除列表ArrayListTaskDetails中不存在的项目VMHArray。
码
Dim Flag : Flag = true
Dim Counter
For IndexSearch = 0 To ArrayListTaskDetails.Count - 1 step 4
Counter = 0
Do while Flag
If VMHArray(Counter) <> ArrayListTaskDetails (IndexSearch) Then
ArrayListTaskDetails.RemoveRange IndexSearch, 4
Flag = False
End If
Counter = Counter + 1
Loop
Next
Run Code Online (Sandbox Code Playgroud)
现在,假设在找到一个匹配项IndexSearch = 0,那么根据它会删除位置上的元素0,1,2,3-很好。但是由于移除并ArrayList通过功能使对象连续,其他元素将4向左移动。现在问题For Loop已经增加了4,因此将从下一个迭代开始location 4。因此,现在0 location数组列表中的新元素再也没有机会测试与VMHArray数组元素的相等性。如果我们可以将For …
我有这个字符串例如:
one two three four START four five four five six END seven
Run Code Online (Sandbox Code Playgroud)
我想在其中搜索单词"four"以用REPLACED替换它,这将给出
one two three four START REPLACED five REPLACED five six END seven
Run Code Online (Sandbox Code Playgroud)
我知道START(.*)END会在两个分隔符之间给出单词.我试过了START(?<four>)END,但它什么都没有.
我在Vbscript工作.
我一直在尝试使用Do Loop,但由于某些原因,当代码遇到do loop命令时,它就会退出.它甚至没有给我任何错误.在此语句之后有大量脚本,但它不会被处理和执行.有没有我可以使用的替代方法,或者我只是做错了?
Do while b = vbRetry
msgbox "Remote Keyboard Control accepted from ip 346.195.639.63"
msgbox "Attempting to Block Connection..."
b = msgbox("Could not block connection.", vbCritical+vbAbortRetryIgnore+vbSystemModal)
Loop
Run Code Online (Sandbox Code Playgroud) 我需要创建一个脚本批处理,PowerShell或VB来将星期几添加到文件名中.
例如,有4个文件,所有都需要在周一将MON挂在前面,周二为TUE,周三为WED等.
有人可以帮忙吗?
我想让我的VB脚本转到后台的URL.它可以在后台打开浏览器并在之后关闭它.越"沉默"越好.我有2个实现可以在我的机器上工作,但不适用于另一个:
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("iexplore.exe " & myURL, 1)
Run Code Online (Sandbox Code Playgroud)
这是另一个:
Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")
objExplorer.Navigate myURL
'Determines if the window is visible or not
objExplorer.Visible = 0
'Suspend the script for 1 minute
WScript.Sleep 6000
'Close the IE (instantiated) window
objExplorer.quit
Run Code Online (Sandbox Code Playgroud)
...其中myURL是包含URL的字符串变量.
我无法弄清楚为什么上面的任何一个在我的笔记本电脑上工作但在服务器上没有.任何帮助,将不胜感激.
我拼凑了以下VBS文件来读取Excel源文件,并使用基于Excel列A的名称和基于列B(连接)的内容创建文件.这一切都有效......
Dim xlsFile
Dim objExcel
Dim outFile
Dim path
path = "C:\Documents and Settings\Andy\Desktop\SHORTURLs\JSPs"
xlsFile = path & "\urls.xls"
Set objExcel = WScript.CreateObject("Excel.Application")
objExcel.Workbooks.open(xlsFile)
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
intRow = 2 'Row 1 contains headings
' Here is the loop that cycles through the cells
Do Until objExcel.Cells(intRow,1).Value = ""
strFile = objExcel.Cells(intRow, 1).Value
strDestURL = objExcel.Cells(intRow, 2).Value
' -- The heart of the create file script
'Set objTextFile = objFSO.CreateTextFile("./" & strFile & …Run Code Online (Sandbox Code Playgroud) 我打开了一个记事本并输入了这个命令:
SystemUtil.Run "C:\Program Files\Google\Chrome\Application\chrome"
并保存了带.vbs扩展名的文件.当我运行它时,它会抛出一个Object Required : SystemUtil错误.但同样的事情贯穿其中QTP.这是为什么?
我有一个充满字符的文本文件:
ABCABCABCABC
Run Code Online (Sandbox Code Playgroud)
...并且使用脚本(Batch,VBS,Powershell,对于Windows来说非常简单)我试图为某个字符的每个实例自动添加一个新行,在本例中为字母A,因此输出将显示为这样:
ABC
ABC
ABC
ABC
Run Code Online (Sandbox Code Playgroud)
如何使用我上面提到的任何脚本工具来完成这项工作?
非常感谢,感谢一帮!
vbscript ×10
excel ×4
excel-vba ×3
vba ×3
batch-file ×2
powershell ×2
asp-classic ×1
browser ×1
dayofweek ×1
directory ×1
qtp ×1
regex ×1
url ×1
windows ×1