FOR to NEXT Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrel
    New Member
    • Nov 2006
    • 72

    FOR to NEXT Problem

    Hi vb Genius i have a question, it like this i'am doing a program that consists of several combo box that are in an array form, i.e combo1(0) to (15), that is the name of the combo boxes, now am having problem.. i want to use a for to next looping.. to locked the combo boxed when i clicked a particular button..
    my code is like this

    Code:
     
    For x = 0 to 15 
        
         combo1(x).Locked = True
    
    Next
    But it seems am forgetting something,, because it doesnt do anything, it doesnt locked the combo boxes, i hope someone can enlighten me up! thank you very much in advance.

    This site is a very medium helpful medium in program, i've got so any answers to my problems in this forum site. That's why i salute to those VB masters that are very helpful to us Newbies. Thank YOu.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    That piece of code would certainly set the .Locked property to True on those 16 controls, but perhaps .Locked doesn't have precisely the effect you expect in a ComboBox.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Can u please specify what do u mean by LOCK a combobox.

      Please what exactly u want to do.

      Comment

      • ansumansahu
        New Member
        • Mar 2007
        • 149

        #4
        Originally posted by darrel
        Hi vb Genius i have a question, it like this i'am doing a program that consists of several combo box that are in an array form, i.e combo1(0) to (15), that is the name of the combo boxes, now am having problem.. i want to use a for to next looping.. to locked the combo boxed when i clicked a particular button..
        my code is like this

        Code:
         
        For x = 0 to 15 
            
             combo1(x).Locked = True
        
        Next
        But it seems am forgetting something,, because it doesnt do anything, it doesnt locked the combo boxes, i hope someone can enlighten me up! thank you very much in advance.

        This site is a very medium helpful medium in program, i've got so any answers to my problems in this forum site. That's why i salute to those VB masters that are very helpful to us Newbies. Thank YOu.

        So the name of the combo boxes on your form are like
        combo10
        combo11
        combo12......

        are you sure of this. And by locked I understand that you do not like the user to select any item from the combo.

        -ansuman sahu

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by ansumansahu
          So the name of the combo boxes on your form are like
          combo10
          combo11
          combo12......
          No, the B6 code provided deals with a control array. This is an amazingly useful concept which unfortunately seems to have been dropped in later versions of VB. The name of all of the controls in this example is Combo1.

          darrel, is it possible that it's the .Enabled property you want to change? This will stop the user changing the value, but I believe it will also prevent the control from receiving the focus, so they can't even pull down the list to look at it. So it may not be what you're after.

          Comment

          • darrel
            New Member
            • Nov 2006
            • 72

            #6
            Thank you so much my progrtam now is working is used .Enabled instead of .Locked...

            And your correct its an array,, i used for able for me to minized my code instead of codeing it one by one, i hope you agree with me.

            Again Thank you very much, Hail to Killer.

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by darrel
              Thank you so much my progrtam now is working is used .Enabled instead of .Locked...

              And your correct its an array,, i used for able for me to minized my code instead of codeing it one by one, i hope you agree with me.

              Again Thank you very much, Hail to Killer.
              Thanks. :)

              And yes, that's what makes control arrays so powerful - you can use loops to do a lot of processing with a little code.

              Unfortunately, as I mentioned, if you move on to the later (.Net) versions of VB, they don't support control arrays. :(

              Comment

              Working...