Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Modules and User Forms Issue

Status
Not open for further replies.

jzecha

Aerospace
Jan 20, 2016
235
US
I am building a Macro that will put holes in a part.

My Module has two subroutines, the first one calls the User Form Up, and then once I fill out the user form with all the hole specifications (Diameter, Depth, and Bottom of Hole Angle) and Click the OK button, it calls to the second subroutine in the Module to then go through the process of asking for Vectors and Loft Surface to put the holes in.

I can't figure out how to use the data from Combo Boxes and Textboxes in my User Form in my Module that gets called from the User Form.

Can anyone give me some help?


Module Sub Routines:
Code:
Sub CatMAIN()

Call frmHoleMenu.Show(Modeless)

End Sub

Code:
Public Sub BuildHolesx()
    
    Dim oPartDoc As PartDocument

...lots of code...

Dim hole1 As Hole
Set hole1 = SF1.AddNewHoleFromPoint(coord(0), coord(1), coord(2), reference4, 10#)

hole1.Type = catSimpleHole
hole1.AnchorMode = catExtremPointHoleAnchor
hole1.BottomType = catVHoleBottom

Dim limit1 As Limit
Set limit1 = hole1.BottomLimit
limit1.LimitMode = catOffsetLimit

Dim length1 As Length
Set length1 = hole1.Diameter
'length1.Value = 10
length1.Value = hDiameter

Dim angle1 As Angle
Set angle1 = hole1.BottomAngle
'angle1.Value = 120
angle1.Value = hAngle

hole1.SetDirection reference1
hole1.ThreadingMode = catSmoothHoleThreading
hole1.ThreadSide = catRightThreadSide
part1.UpdateObject hole1

End Sub

Userform OK Button Routine:
Code:
Private Sub btnOK_Click()

Dim hDiameter As Length
Dim hDepth As Length
Dim hAngle As Angle

Set hDiameter = frmHoleMenu.txtbxDiameter.Value
Set hDepth = frmHoleMenu.txtbxDepth.Value
Set hAngle = frmHoleMenu.txtbxAngle.Value


    Me.Hide
    Call BuildHoles
    frmHoleMenu.Hide


End Sub
 
Replies continue below

Recommended for you

You have to populate the data with generic VB coding methods.

To populate:

Code:
CBoxOptions = Array("Option 1", "Option 2", "Option 3")
ComboBox3.List = CBoxOptions



 
I understand that, I would like to know how to use that option selected in the Combobox in my code in the modules.

For example, the Textbox values I can't get to work and then I cant get them to be referenced in my second module.
 

I was able to call the value with UserFormName.ComboBox.Value between Userforms. I'm not sure if Userform-->Module behaves differently.

My test was a combobox on userform1 and an apply button on userform2. Why don't you just try to call those dims directly in your buildholes module? take that code out of the OK button completely.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top