Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

For Loop

Hello

In this script I would to show the msgBox referred to the content of variavle. It soesn't work. Please coul to correct What I wrote.


sub var


set a= ActiveDocument.Variables("Variable1")
a.SetContent "4" , true

FOR I=1 to Variable1

.msgBox("Hello")

Next

end sub

Thanks

Best regrds

Slash

5 Replies
biester
Specialist
Specialist

Hi,

I don't know what you intend with it, but the correct code should be:


sub var
set a= ActiveDocument.Variables("Variable1")
' setting the content
a.SetContent "4",true

' reading the content
value = a.GetContent.String
for i = 1 to value
msgbox "Hello"
next
end sub


Don't mix up variables from the qvw-application and variables from the module. You can't mix them!

Rgds,
Joachim

Not applicable
Author

Hi,

thnks. Yes is what I'm lookung for.

Please , if I want to add the counter how I do.

Example (do not work)

sub var
set a= ActiveDocument.Variables("Variable1")
' setting the content
a.SetContent "4",true

' reading the content
value = a.GetContent.String
for i = 1 to value

msgbox "Hello"+ i
next
end sub

the value of o is avaiable?

thanks

Best regards

Slash

biester
Specialist
Specialist

The value of "o"?? What "o"?

Nevertheless, it must be

msgbox "Hello" & i

It's a string concatenation, not an addition.

Rgds,
Joachim

Not applicable
Author

Zero?

The i value is 1 the first ... and 4 the last

Now works. Pleas try the script to understand What I would to do ..

The documentation is many time enough or bad explained.

The part of APi, VBscript is very enough.

thanks

Slash

biester
Specialist
Specialist

Yes, of course, if value = 4 and you start

for i = 1 to value

then i starts with 1 and ends with 4.

Everything clear now?

Rgds,
Joachim