Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

Select in ListBox via VB Code

Hi all

can a selection of 2 or more items in a listbox be done via code in VB?

ActiveDocument.Fields("SalesRep").Select "ABC" works fine but how can I select more than just one, say "ABC" and "BCD" and "CDE"

Thanks

Josh

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   

sub Select_Value
rem ** cancel selection of first selected value **
set f = ActiveDocument.Fields("SalesRep")
set fv = f.GetSelectedValues
fv.RemoveAt 0
f.SelectValues fv

rem ** select two non-consecutive field values in field **
set f = ActiveDocument.Fields("SalesRep")
set fv = f.GetNoValues 'empty array
fv.Add
fv.Add
fv(0).Text = "ABC"
fv(0).IsNumeric = false
fv(1).Text = "BCD"
fv(1).IsNumeric = false
f.SelectValues fv

end sub

Regards,

Kaushik Solanki    

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

2 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   

sub Select_Value
rem ** cancel selection of first selected value **
set f = ActiveDocument.Fields("SalesRep")
set fv = f.GetSelectedValues
fv.RemoveAt 0
f.SelectValues fv

rem ** select two non-consecutive field values in field **
set f = ActiveDocument.Fields("SalesRep")
set fv = f.GetNoValues 'empty array
fv.Add
fv.Add
fv(0).Text = "ABC"
fv(0).IsNumeric = false
fv(1).Text = "BCD"
fv(1).IsNumeric = false
f.SelectValues fv

end sub

Regards,

Kaushik Solanki    

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jduenyas
Specialist
Specialist
Author

Thank you!

Every such little hint helps build up the knowledge.

Much appreciated.

Josh