Solved

shortcut

Posted on 1998-12-05
11
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 10 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 75
using web browser with BING 40 150
How to hault or freeze parent form when a 2d form is open in vb6 3 47
MS SQL Update query with connected table data 3 80
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

739 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