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
Solved

shortcut

Posted on 1998-12-05
11
208 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 41
passing parameter in sql procedure 9 65
VB6 - Scroll Mouse wheel on Picturebox 13 73
Collapse and expand table in Word 2010 2 36
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 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