简体   繁体   English

脚本 sap 循环

[英]script sap loop

i need some help here, i have a command for script sap(vba) where i just need to change a number am each line, is there a way to have just one line and create a loop?我需要一些帮助,我有一个脚本 sap(vba) 的命令,我只需要在每行更改一个数字,有没有办法只有一行并创建一个循环? num1 = 5, num2 = 9, num3 = 10数字 1 = 5,数字 2 = 9,数字 3 = 10

session.findById("wnd[1]/usr/chk[2,5]").Selected = True
session.findById("wnd[1]/usr/chk[2,9]").Selected = True
session.findById("wnd[1]/usr/chk[2,10]").Selected = True

what i hope我希望什么

session.findById("wnd[1]/usr/chk[2,numX]").Selected = True

for example:例如:

For numx = 5 To 13 Step 4
    If numx = 13 Then numx = 10
    session.findById("wnd[1]/usr/chk[2," & cstr(numx) & "]").Selected = True
next

Regards, ScriptMan问候, ScriptMan

Another way using a For Each loop.使用 For Each 循环的另一种方法。

Sub Test()

    Dim vNums() As Variant
    vNums = Array(5, 9, 10)
    
    Dim vNum As Variant
    For Each vNum In vNums
        session.findById("wnd[1]/usr/chk[2," & vNum & "]").Selected = True
    Next vNum
    
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM