×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Combo Box VB Question & SW
2

Combo Box VB Question & SW

Combo Box VB Question & SW

(OP)
I am in need of the code required to add a simple combo box to an existing macro.  I would like to have the abilty to select an individual user name from a A pull down list.

Also is there an easy way to force upper case text in a text box?

Please be as descriptive and possibly provide the code as I am just beginning VB and have no clue.

Not sure if it's important but all of my code for the macro is associated with the userform.

RE: Combo Box VB Question & SW

Combobox works like it does for jsut about any other VBA app.  Just drag one in to the form when in the VB editor environment and set it up.

All this machinery making modern music can still be open hearted.

RE: Combo Box VB Question & SW

RC2003

Like the Tick said you insert the combobox into the form.  Then in the vb editor enter:

'fill cbo box
'cbo_byl is the name of the combo box on the form
    cbo_byl.AddItem "  "
    cbo_byl.AddItem "DH"
    cbo_byl.AddItem "CB"
    cbo_byl.AddItem "LAN"

RE: Combo Box VB Question & SW

You can force the text to upper case using the UCase(String) function.  For example, if you wanted the text in TextBox1 to convert to upper case you would write TextBox1.Value = UCase(TextBox1.Value).

RE: Combo Box VB Question & SW

If correctly parsing variables is your goal here (Im assuming you are capitalizing so you only have to do one string comparison) use a ListBox instead of a ComboBox.

The combobox will/can allow them to type in their own entries, and to catch THAT requires a lot more work.

RE: Combo Box VB Question & SW

The mistake I made when writing our Title Box VB program. I put the engineers, designers, and drafter’s names in a list box instead of outside the program in a text file.  Now only I can add names to the automatically filled in text box. Bad move. I also put the finishes, materials, and material sizes in code.  Now every change has to be done by me. If you are just starting get a good VB box and write data that will change outside the VB code.
Good luck.

Bradley

RE: Combo Box VB Question & SW

Bradley's suggestion is a good one.  The whole point of using a vb routine to enter custom properties instead of using the SWX interface is that the user can have list boxes, combo boxes and radio buttons etc to help minimize the amount of manual data entry.  If you hard code the data into the program then someone has to maintain the lists.  The better solution is to hold the data in a text file and let the user customize the file.  The vb routine can then look for the text file and populate the controls accordingly.  

There are a couple of examples on the SWX website which can help you with this project.  There is a vb custom property program in the model library which you can easily customize.  I went a step further and integrated the custom property code into the SWX property manager page instead of using a separate form.  I like this approach because it is completely integrated with the parent program.  There is also an example showing how to create a property manager page using vba in the api section of the SWX website.

RE: Combo Box VB Question & SW

Another way to force upper case is to put this statement:

KeyAscii = Asc(UCase$(Chr$(KeyAscii)))

into the combo box KeyPress event.  That way the user will only see upper case letters as they are typed.

Regg

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources