- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning
Previously I asked about run VBA inside another VBA code HERE
and thanks for alfred.NESWADBA he gave me a great solution ,
but I faced a little problem I couldn't fix it
here is the code of userform1 :
Private Sub CommandButton1_Click() Dim length As Double, width As Double, height As Double, center(0 To 2) As Double Dim box1 As Acad3DSolid center(0) = txt1 * 0.5: center(1) = txt2 * 0.5: center(2) = txt3 * 0.5 length = txt1: width = txt2: height = txt3 Set box1 = ThisDrawing.ModelSpace.AddBox(center, length, width, height) ZoomAll Call LeftBoring.ThisDrawing.LeftBoring Call rightboring.ThisDrawing.rightboring Unload Me End Sub
and 2 codes for boring I will write one of them
here is the code of Leftboring :
Public Sub LeftBoring() 'NFR= number of Rows 'NFC= number of columns 'NFL= number of levels 'DBR= distance between Rows 'DBC= distance between columns 'DBL= distance between levels Dim center(0 To 2) As Double, RADIUS As Double Dim NFR As Long, NFC As Long, NFL As Long, DBR As Double, DBC As Double, DBL As Double Dim RECTARRY As Variant If txt2 < 24 Then MsgBox "Length Should be equal or more than 24 mm." Else If txt2 < 60 Then center(1) = txt2 / 2: center(0) = 9: center(2) = txt3: RADIUS = 2.5 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) Else If txt2 < 100 Then center(1) = (txt2 - 32) / 2: center(0) = 9: center(2) = txt3: RADIUS = 2.5 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) center(1) = ((txt2 - 32) / 2) + 32: center(0) = 9: center(2) = txt3: RADIUS = 4 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) Else If txt2 < 125 Then center(1) = txt2 / 2: center(0) = 9: center(2) = txt3: RADIUS = 2.5 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) center(1) = (txt2 - 64) / 2: center(0) = 9: center(2) = txt3: RADIUS = 4 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) NFR = 1: NFC = 2: NFL = 1: DBR = 1: DBC = 64: DBL = 1 RECTARRY = circ.ArrayRectangular(NFC, NFR, NFL, DBC, DBR, DBL) Else If txt2 < 171 Then center(1) = txt2 / 2: center(0) = 9: center(2) = txt3: RADIUS = 4 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) center(1) = (txt2 - 64) / 2: center(0) = 9: center(2) = txt3: RADIUS = 2.5 Set circ = ThisDrawing.ModelSpace.AddCircle(center, RADIUS) NFR = 1: NFC = 2: NFL = 1: DBR = 1: DBC = 64: DBL = 1 RECTARRY = circ.ArrayRectangular(NFC, NFR, NFL, DBC, DBR, DBL) Else MsgBox "Length Should be less than 171 mm." End If End If End If End If End If End Sub
End Sub
And I added the boring code as a reference to first code .
txt1 , txt2 and txt3 are textbox in userform1 .
when I try to run the code , its work good and give me message box from second code
MsgBox "Length Should be equal or more than 24 mm."
its appear if value is less than 24 mm, but in user form value is greater than 24 .
How to make the second code take values from userform1 (txt1,txt2 and txt3) ?
I'll attach the .dvb files
Solved! Go to Solution.