on 05-07-2015 8:10 PM
Good Day!
Hope you can guide me on how to do below.
I have the VB line and I would like to run the script multiple times - changing the value inside the quotation marks ("").
session.findById("wnd[1]/usr/sub:SAPLSWOT:0200/ctxtOBJID-VALUE[0,21]").text = "XXXXXXXXXX"
How do you do this? Thanks!
Jayj
Hello Joseph,
welcome to this forum.
You can do it e.g. like this:
For i = 1 to 10
varText = CStr(i)
session.findById("wnd[1]/usr/sub:SAPLSWOT:0200/ctxtOBJID-VALUE[0,21]").text = varText
Next
In this case you set the content of to 1, 2, 3 ... 10 - as character.
Or you can do this:
For i = 1 to 10
varText = "4711" & CStr(i) & "Ja"
session.findById("wnd[1]/usr/sub:SAPLSWOT:0200/ctxtOBJID-VALUE[0,21]").text = varText
Next
In this case you set the content to 47111Ja, 47112Ja, 47113Ja ... 471110Ja.
Important is to use a variable to set the content.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for this Stefan!
Is there a way where I won't need to declare it one by one? I'm thinking of using an array but that will have the same problem. I have around 50-70 strings that I need to loop on so setting it to the variable may be tedious. And each string can be random so I'm having a hard time integrating it with a counter inside a for loop.
Jayj
Hello Jayj,
the loop with the counter was only an example.
You can contain it into a function:
Function setText(varText)
session.findById("wnd[]1]/usr/sub:SAPLSWOT:0200/ctextOBJID-VALUE[0,21]").text = varText
End Function
With this way you can set the text in your Loop, e.g. like this:
Dim arText("YourText1", "YourText2", "YourText3")
For Each Text in arText
setText(Text)
Next
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.