Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

shortcut

Posted on 1998-12-05
11
Medium Priority
?
218 Views
Last Modified: 2010-05-03
I have several listboxes but i want to show only one of them at a time. I used the following code. Though it worked fine but it is very lengthy.If anybody could tell me any shortcut?

If Node.Index = 13 Then
  List1.Visible = False
  List2.Visible = False
  List3.Visible = True
  List4.Visible = False
  List5.Visible = False
 
ElseIf Node.Index = 14 Then
 List1.Visible = False
  List2.Visible = False
  List3.Visible = False
  List4.Visible = True
  List5.Visible = False
 
 Elseif ...... and so on
0
Comment
Question by:mailsuhail
  • 5
  • 2
  • 2
  • +1
11 Comments
 

Author Comment

by:mailsuhail
ID: 1448398
Edited text of question
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1448399
Define your list boxes as a CONTROL ARRAY. Then you'll have:

FOR Ndx = 1 to Number_of_controls
 IF Ndx = Desired_number THEN
    List1(Ndx).Visible = True
 ELSE
    List1(Ndx).Visible = False
 ENDIF
NEXT Ndx
0
 

Author Comment

by:mailsuhail
ID: 1448400
I have 6 list boxes. the above code only hides the selected one but the rest of them were still visible.what i need is that only one of them should be visible at one time. thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mailsuhail
ID: 1448401
I have 5 list boxes. the above code only hides the selected one but the rest of them were still visible.what i need is that only one of them should be visible at one time. thanks.



    If list1.listindex =1 Then
      List1.Visible = False
      List2.Visible = False
      List3.Visible = True
      List4.Visible = False
      List5.Visible = False
       
    ElseIf list1.listindex = 2 Then
     List1.Visible = False
      List2.Visible = False
      List3.Visible = False
      List4.Visible = True
      List5.Visible = False
       
     Elseif ...... and so on





0
 

Author Comment

by:mailsuhail
ID: 1448402
I have 5 list boxes. the above code only hides the selected one but the rest of them were still visible.what i need is that only one of them should be visible at one time. thanks.



    If list1.listindex =1 Then
      List1.Visible = False
      List2.Visible = False
      List3.Visible = True
      List4.Visible = False
      List5.Visible = False
       
    ElseIf list1.listindex = 2 Then
     List1.Visible = False
      List2.Visible = False
      List3.Visible = False
      List4.Visible = True
      List5.Visible = False
       
     Elseif ...... and so on





0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1448403
Q why did you reject mailsuhail answer ??? It should work ...


0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1448404
Q why did you reject mailsuhail answer ??? It should work ...


0
 
LVL 7

Accepted Solution

by:
Inteqam earned 40 total points
ID: 1448405
if i understood you Q,
try this:

list1.visible=false
list2.visible=false
list3.visible=false
list4.visible=false
list5.visible=false

if list1.listindex =1 then
    list3.visible=true
elseif list1.listindex =2 then
    list4.visible=true
elseif....... and so on.
 
or use a case statemenet as follow

list1.visible=false
list2.visible=false
list3.visible=false
list4.visible=false
list5.visible=false

select case list1.listindex
 case 1:
    list3.visible=true
case 2:
    list4.visible=true
case 3 :
..... and so on.
end select


hope you the best

0
 

Author Comment

by:mailsuhail
ID: 1448406
thank you
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1448407
My answer worked as well.

M

0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1448408
sorry mark2150 , i didn't see your answer ,but i think it works.

what can i do?

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question