Set Textbox Controls

  • Hi all,

    Is there an easier way of setting the values of textbox controls, the way im using below is very repetitive and has to be run through every time a combobox1 is changed. Im also going to have to add a lot more case scenarios in the short future.

  • Re: Set Textbox Controls


    • Put them in Group Boxes?
    • You could name them in a similar manner to what has been selected from your listbox, and loop through all of the controls looking for that name, then set your properties.
    • Instead of naming them, you could set the tag property to "Hughes" or "Bell" and then loop through them looking for the tag that corresponds to the selection from the list box.


  • Re: Set Textbox Controls

    Hi G, Thanks for that advise.

    What do you mean by group boxes? The text boxes are in frames at the moment but not nessacarily the right "group".

    I dont think I can do option 2 or 3 because the boxes are used by more than one aircraft. Ie I couldnt tag or rename because for example textbox 8 is in bell206b and as350B3 but locked in only bell206B.

    But I will definately try tho.

    Its a nasty situation I think, maybe I have to live with it?

  • Re: Set Textbox Controls


    Sorry. Frames = Group Boxes.

    The only other thing I can think of is to call a Function.

    i.e. instead of

    TextBox8.Enabled = False 
            TextBox8.Locked = True 
            TextBox8.Value = "N/A"

    Do this:

    Call TextBoxEnabler(Me.TextBox8,Xeng)
    'and then
    Private Function TextBoxEnabler(Byval tbx as TextBox, Byref Xeng as Boolean) as Boolean
            tbx.Enabled = Xeng 
            tbx.Locked = Not Xeng
            tbx.Value = IIf(Xeng, "N/A","")
    End Function


  • Re: Set Textbox Controls

    Hi G,

    That last peice of code could well be what I'm after. HoweverI cant seem to get it to work I get a "Byref argument type Mismatch".

    If I change Xeng to true. I get "Type Mismatch".

    Have played around with it quite a bit, any ideas?


  • Re: Set Textbox Controls

    Hi Guys,

    Thanks for your help.

    I now have the following code which I feel is a definate improvement on my original lot. It now caters for additional aircraft to be easily loaded in. Unfortunately I had to set the textbox variables for the textbox individualy but I dont think that really matters.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!