Solved

shortcut

Posted on 1998-12-05
11
203 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now