comcu Posted September 14, 2008 Share Posted September 14, 2008 Hi, Is it possible to store the values of an array to be used later. I create an array of text boxes on one form and then do a For I = 0 To Cnt .... .... ... next i use the values of the arrayed text boxes to position mlines in my drawing. I then hide the form and open up the 2nd form. this also has an array of text boxes. i use the values of them to position mlines within my drawing. the problem is now i need the values from the previous forms arrayed text boxes to use in a calculation on the 2nd(current) form. i have tried to store them in a public dim but it dosent seem to work i think i would need to do some thing like this but not sure if it is possible sub form1 Cnt1 = 5 For I = 0 to Cnt1 TxtBoxFrm1(I).value next end sub sub frm2 cnt2 = 5 For I = 0 to Cnt2 TxtBoxFrm1Tot = TxtBoxFrm1Tot + TxtBoxFrm1(I).value point(0) = 50 point(1) = TxtBoxFrm1Tot + ...etc point(2) = 0 etc etc next end sub what i am trying to do is use the Txtbox1(0).value the first time the sub Frm2 runs the the second time use Txtbox1(1).value then Txtbox1(2).value Is this possible? i hope that makes sense? cheers, col Quote Link to comment Share on other sites More sharing options...
rocheey Posted September 15, 2008 Share Posted September 15, 2008 Declaring your array(s) as "Public", in a code module, will work. You can then reference them from each form module as if the variables were declared within each form module. Be aware that you don't also declare them within the code module, either at the top of the module, or within a routine, because that will override the Public declare you made in the other module. Im not sure if the code you posted was actual code, so there is no way of telling whether you actually declared public arrays, but the code I see doesnt really do anything, and Im having a hard time picturing how the following code can run without errors: For I = 0 to Cnt1 TxtBoxFrm1(I).value next Without being able to check, Im going to guess that you declared your public arrays correctly, and its everything else that isnt working. Quote Link to comment Share on other sites More sharing options...
comcu Posted September 15, 2008 Author Share Posted September 15, 2008 Rocheey, Main form code Public LHTOL As Double Public RHTOL As Double Public BTMTOL As Double Public TOPTOL As Double Public CwWid As Double Public MyTranYpos As Double Public Sub constants() Ypos = TxtbxTransomYSrtPos LHTOL = TxtBxTolLH.Value RHTOL = TxtBxTolRH.Value BTMTOL = TxtBxTolBtm.Value TOPTOL = TxtBxTolTop.Value CwWid = TxtBxCWWid.Value End Sub Private Sub CmdCreateCW_Click() CreateStrucOp End Sub Private Sub CreateStrucOp() 'this sub reates the perimeter structural opening rectangle Dim plineObj_SO As AcadLWPolyline Dim points(0 To 9) As Double Dim color As AcadAcCmColor Set color = _ AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17") Call color.SetRGB(255, 127, 0) ' Define the 2D polyline points points(0) = 0: points(1) = 0 points(2) = TxtBxSOWid.Value: points(3) = 0 points(4) = TxtBxSOWid.Value: points(5) = TxtBxSOHght.Value points(6) = 0: points(7) = TxtBxSOHght.Value points( = 0: points(9) = 0 ' Create a light weight Polyline object in model space Set plineObj_SO = ThisDrawing.ModelSpace. _ AddLightWeightPolyline(points) ThisDrawing.Application.ZoomAll plineObj_SO.Layer = "0" plineObj_SO.Linetype = "HIDDEN" plineObj_SO.LinetypeScale = TxtBxSOWid.Value * TxtBxSOHght.Value / 2# plineObj_SO.TrueColor = color ZoomAll CreateLhMull End Sub Private Sub CreateLhMull() 'this sub creates the left hand mullion Dim StrucOpHght As Double Dim mLineObj_LhMull As AcadMLine Dim points(0 To 5) As Double StrucOpHght = TxtBxSOHght.Value StrucOpWid = TxtBxSOWid.Value ThisDrawing.SetVariable "CMLSTYLE", TxtBxMLineStyle.Value '<--style name ' Define the 2D polyline points points(0) = TxtBxCWWid / 2 + TxtBxTolLH: points(1) = TxtBxTolBtm: points(2) = 0 points(3) = TxtBxCWWid / 2 + TxtBxTolLH: points(4) = StrucOpHght - TxtBxTolTop: points(5) = 0 'points(2) = TxtBxSOWid.Value * 1000#: points(3) = 0 ' Create a light weight Polyline object in model space Set mLineObj_LhMull = ThisDrawing.ModelSpace. _ AddMLine(points) ThisDrawing.Application.ZoomAll mLineObj_LhMull.Layer = "0" mLineObj_LhMull.MLineScale = TxtBxCWWid mLineObj_LhMull.Update CreateRhMull End Sub Private Sub CreateRhMull() 'this sub creates the Right hand mullion Dim StrucOpHght As Double Dim StrucOpWid As Double Dim mLineObj_RhMull As AcadMLine Dim points(0 To 5) As Double StrucOpHght = TxtBxSOHght.Value StrucOpWid = TxtBxSOWid.Value 'ThisDrawing.SetVariable "CMLSTYLE", "STANDARD" '<--style name ThisDrawing.SetVariable "CMLSTYLE", TxtBxMLineStyle.Value '<--style name ' Define the 2D polyline points points(0) = StrucOpWid - TxtBxTolRH - TxtBxCWWid / 2: points(1) = TxtBxTolBtm: points(2) = 0 points(3) = StrucOpWid - TxtBxTolRH - TxtBxCWWid / 2: points(4) = StrucOpHght - TxtBxTolTop: points(5) = 0 ' Create a light weight Polyline object in model space Set mLineObj_LhMull = ThisDrawing.ModelSpace. _ AddMLine(points) ThisDrawing.Application.ZoomAll mLineObj_LhMull.Layer = "0" mLineObj_LhMull.MLineScale = TxtBxCWWid mLineObj_LhMull.Update 'Run End Sub Sub Run() 'UFrmAutoDrawCW.Hide 'UFAutoDrwCwMullInpt.Show End Sub Private Sub CmdEnd_Click() MsgBox "Button Does Nothing" End Sub Private Sub CmdExit_Click() End End Sub Private Sub CmdMnFrmNext_Click() constants MsgBox "Button Does Nothing" End Sub Private Sub CmdOpenCntMullFrm_Click() UFrmAutoDrawCW.Hide UFAutoDrwCwMullInpt.Show End Sub Private Sub UserForm_Click() End Sub 1st form code Public I As Integer Public Cnt Public CntMullionQty Dim TxtbxMullionXSrtPos() As MSForms.TextBox Dim Lbls() As MSForms.Label Private Sub CmdClearForm_Click() 'UFAutoDrwCwMullInpt Unload Me UFAutoDrwCwMullInpt.Show End Sub Private Sub CmdCreate_Click() UFAutoDrwCwMullInpt.Caption = "Mullion Calculation..... Note: End Bay is Calculated Automatically" CreateMullionTextBox CreateMullionLabels End Sub Private Sub CreateMullionTextBox() Dim numButtons As Integer: numButtons = TxtBxMullNum.Value ReDim TxtbxMullionXSrtPos(numButtons) 'Dim I As Integer CntMullionQty = numButtons numButtons = numButtons - 3 Cnt = numButtons For I = 0 To numButtons '- 2# ' create a control on the fly Set TxtbxMullionXSrtPos(I) = Me.Controls.Add("Forms.textbox.1", "TxtbxMullionXSrtPos" & LTrim$(Str$(I)), True) ' set its position and size TxtbxMullionXSrtPos(I).Height = 20: TxtbxMullionXSrtPos(I).top = 70 TxtbxMullionXSrtPos(I).Left = 5 + (I * 40) + 5: TxtbxMullionXSrtPos(I).Width = 35 Next I Me.Width = 700 Me.Height = 200 Me.Left = 150 CreateMullionLabels End Sub Private Sub CreateMullionLabels() Dim numLabels As Integer: numLabels = TxtBxMullNum.Value ReDim Lbls(numLabels) Dim MyStrLblBayNo For I = 0 To numLabels - 3 ' create a control on the fly 'Set Lbls(I) = Me.Controls.Add("Forms.Label.1", "Lbls" & LTrim$(Str$(I)), True) Set Lbls(I) = Me.Controls.Add("Forms.label.1", "Lbls" & LTrim$(Str$(I)), True) 'Set Lbls(I) = Me.Controls.Add("Forms.label.1")'works for 1No ' set its position and size Lbls(I).Height = 20: Lbls(I).top = 40 Lbls(I).Left = 5 + (I * 40) + 5: Lbls(I).Width = 35 'Lbls(I).Caption = " Bay No." & I Lbls(I).Caption = " Bay Width No." & I + 1 Next I ' resize the form around the text boxes 'Me.Width = 200 'Me.Height = 35 + ((numLabels + 2) * 25) UFAutoDrwCwTranInpt.ScrollWidth = 2 + ((numLabels + 2) * 30) * 2 End Sub Private Sub CmdCreateMullions_Click() 'this sub creates the intermediate mullion Dim MyMullPositionVar As Variant Dim StrucOpHght As Double Dim mLineObj_InterMMull As AcadMLine Dim points(0 To 5) As Double Dim MyCWWidTot As Double Dim MyTotBayWidths As Double Dim CntMullion As Double Dim MyTranXPos As Double For I = 0 To Cnt MyBayWidVar = TxtbxMullionXSrtPos(I).Value ''' this is the point the bay width is stored in memory 'MyCWWidTot = CntMullionQty '* 0.5 CntMullion = CntMullion + 1 If CntMullion = "1" Then CntMullion = CntMullion * 1.5 MyTotBayWidths = MyTotBayWidths + MyBayWidVar StrucOpHght = UFrmAutoDrawCW.TxtBxSOHght.Value StrucOpWid = UFrmAutoDrawCW.TxtBxSOWid.Value ThisDrawing.SetVariable "CMLSTYLE", UFrmAutoDrawCW.TxtBxMLineStyle.Value '<--style name ' Define the 3D multiline points points(0) = UFrmAutoDrawCW.TxtBxTolLH + UFrmAutoDrawCW.TxtBxCWWid * CntMullion + MyTotBayWidths: points(1) = UFrmAutoDrawCW.TxtBxTolBtm: points(2) = 0 points(3) = UFrmAutoDrawCW.TxtBxTolLH + UFrmAutoDrawCW.TxtBxCWWid * CntMullion + MyTotBayWidths: points(4) = StrucOpHght - UFrmAutoDrawCW.TxtBxTolTop: points(5) = 0 ' Create a light weight Polyline object in model space Set mLineObj_InterMMull = ThisDrawing.ModelSpace. _ AddMLine(points) ThisDrawing.Application.ZoomAll mLineObj_InterMMull.Layer = "0" mLineObj_InterMMull.MLineScale = UFrmAutoDrawCW.TxtBxCWWid mLineObj_InterMMull.Update MyTranXPos = TxtbxMullionXSrtPos(I).Value MyTranXPos Next End Sub Private Sub CmdMullFrmNext_Click() UFAutoDrwCwMullInpt.Hide UFAutoDrwCwTranInpt.Show End Sub Private Sub CmdStorValues_Click() Dim MyMullPositionVar As Variant For I = 0 To Cnt MyMullPositionVar = TxtbxMullionXSrtPos(I).Value MsgBox MyMullPositionVar Next End Sub Private Sub CommandButton1_Click() UFAutoDrwCwMullInpt.Hide UFrmAutoDrawCW.Show End Sub Private Sub UserForm_Initialize() 'UFAutoDrwCwMullInpt.Height = "50" 'UFAutoDrwCwMullInpt.Width = "368" End Sub Quote Link to comment Share on other sites More sharing options...
comcu Posted September 15, 2008 Author Share Posted September 15, 2008 2nd form code Public I As Integer Public Cnt Public CntTransomQty Dim TxtbxTransomYSrtPos() As MSForms.TextBox Dim Lbls() As MSForms.Label Private Sub CmdClearForm_Click() 'UFAutoDrwCwTranInpt Unload Me UFAutoDrwCwTranInpt.Show End Sub Private Sub CmdCreate_Click() UFAutoDrwCwTranInpt.Caption = "Transon Calculation..... Note: End Bay is Calculated Automatically" CreateTransomTextBox CreateTransomLabels End Sub Private Sub CreateTransomTextBox() Dim numButtons As Integer: numButtons = TxtBxTranNum.Value ReDim TxtbxTransomYSrtPos(numButtons) 'Dim I As Integer CntTransomQty = numButtons numButtons = numButtons - 1 Cnt = numButtons For I = 0 To numButtons '- 2# ' create a control on the fly Set TxtbxTransomYSrtPos(I) = Me.Controls.Add("Forms.textbox.1", "TxtbxTransomYSrtPos" & LTrim$(Str$(I)), True) ' set its position and size TxtbxTransomYSrtPos(I).Height = 20: TxtbxTransomYSrtPos(I).Width = 100 TxtbxTransomYSrtPos(I).Left = 5: TxtbxTransomYSrtPos(I).top = 35 + (I * 25) + 5 Next I ' resize the form around the text boxes Me.Height = 400 Me.top = 30 Me.Left = 200 'Me.Height = 35 + ((numButtons + 2) * 25) 'Me.Width = 5 + ((numButtons + 2) * 40) 'CreateTransomLabels End Sub Private Sub CreateTransomLabels() Dim numLabels As Integer: numLabels = TxtBxTranNum.Value ReDim Lbls(numLabels) Dim MyStrLblBayNo For I = 0 To numLabels - 3 ' create a control on the fly Set Lbls(I) = Me.Controls.Add("Forms.label.1", "Lbls" & LTrim$(Str$(I)), True) 'Set Lbls(I) = Me.Controls.Add("Forms.label.1")'works for 1No ' set its position and size Lbls(I).Height = 20: Lbls(I).Width = 100 Lbls(I).Left = 105: Lbls(I).top = 35 + (I * 25) + 5 'Lbls(I).Height = 20: Lbls(I).Width = 100 'Lbls(I).Left = 105: Lbls(I).top = 35 + (I * 25) + 5 'Lbls(I).Caption = " Bay No." & I Lbls(I).Caption = " CL Transom No." & I + 1 Next I ' resize the form around the text boxes 'Me.Width = 200 'Me.Height = 35 + ((numLabels + 2) * 25) UFAutoDrwCwMullInpt.ScrollHeight = 35 + ((numLabels + 2) * 25) * 10 End Sub Private Sub CmdBCreateTransom1Row_Click() 'this sub creates the intermediate Transom Dim mLineObj_Tran1stRow As AcadMLine Dim points(0 To 5) As Double Dim MyTranYpos As Double LHTOL = UFrmAutoDrawCW.TxtBxTolLH.Value RHTOL = UFrmAutoDrawCW.TxtBxTolRH.Value BTMTOL = UFrmAutoDrawCW.TxtBxTolBtm.Value TOPTOL = UFrmAutoDrawCW.TxtBxTolTop.Value CwWid = UFrmAutoDrawCW.TxtBxCWWid.Value For I = 0 To Cnt MyTranYpos = TxtbxTransomYSrtPos(I).Value ThisDrawing.SetVariable "CMLSTYLE", UFrmAutoDrawCW.TxtBxMLineStyle.Value '<--style name ' Define the 3D multiline points points(0) = UFrmAutoDrawCW.TxtBxTolLH + UFrmAutoDrawCW.TxtBxCWWid * 1: points(1) = MyTranYpos: points(2) = 0: points(3) = 560 'LHTOL + CwWid + Ypos points(4) = points(1): points(5) = 0: ' Create a light weight Polyline object in model space Set mLineObj_Tran1stRow = ThisDrawing.ModelSpace. _ AddMLine(points) 'ThisDrawing.Application.ZoomAll mLineObj_Tran1stRow.Layer = "0" mLineObj_Tran1stRow.MLineScale = UFrmAutoDrawCW.TxtBxCWWid mLineObj_Tran1stRow.Update Next End Sub Private Sub CmdStorValues_Click() Dim MyTranPositionVar As Variant For I = 0 To Cnt MyTranPositionVar = TxtbxTransomYSrtPos(I).Value MsgBox MyTranPositionVar Next End Sub Private Sub CmdTranFrmNext_Click() UFAutoDrwCwTranInpt.Hide UFrmAutoDrawCW.Show End Sub Private Sub UserForm_Initialize() 'UFAutoDrwCwTranInpt.Height = "80" UFAutoDrwCwTranInpt.Width = "368" End Sub for example the value of the first text box on the 1st form is 500, LHTOL = 10, CwWid = 50 which makes 560. so i want point(3) to be 560. points(3) = 560 'LHTOL + CwWid + Ypos Cheers, Col Quote Link to comment Share on other sites More sharing options...
rocheey Posted September 15, 2008 Share Posted September 15, 2008 well, Im still a bit lost - I started editing your code after your first post - then, afterwards, I saw another post, and that there is a "main form", and a "first form", and a "second form" .. so I wont bother posting the cleaned up code for the single form I edited... The problem I saw, is 2-fold: one, you must declare your globals from a CODE module, not a form module. Secondly, even after you are declaring your globals, you werent USING them anywhere. However, you are doing the right thing with your "Sub Constants" routine - which is the following: have a routine, in each form, that sets the value of the text boxes to the Global variables you MOVED to your code module. But THEN, stop referencing the text boxes *anywhere else*. There should only be *one line* of code that references your text box - the one that sets the text box value into the global variable. From then on, use the global value - otherwise, you are using 2 sets of variables, that may have different values. Also, Id *rename* your "Sub Constants" to something else - like "Sub SeedVariables" - because they arent constants, its confusing, and its too close to a real reserved VBA name. Then move ALL routines, that no longer reference form variables, out of the form module, and into your code module. Quote Link to comment Share on other sites More sharing options...
comcu Posted September 15, 2008 Author Share Posted September 15, 2008 Rocheey, when you say code module what do you mean? Col Quote Link to comment Share on other sites More sharing options...
rocheey Posted September 15, 2008 Share Posted September 15, 2008 Rocheey, when you say code module what do you mean? Col When in the VBA IDE, you can click the "Insert" menu, and then have a choice of "UserForm", "Module", or "Class Module". I meant "Module". Since two of those 3 choices have the word "Module" in them, I, and others, refer to a "Module" as a "Code Module", as opposed to a "Class Module". (and if you arent confused yet, a Userform IS a class Module) Quote Link to comment Share on other sites More sharing options...
comcu Posted September 15, 2008 Author Share Posted September 15, 2008 Ok. . . no i understand well at least up to the "userform is a class module" thanks for the help i will have ago later today. cheers, col Quote Link to comment Share on other sites More sharing options...
comcu Posted September 15, 2008 Author Share Posted September 15, 2008 Rocheey, thank you for the help, i have played around with the code and when the code runs on the second form it does grab the value of the textbox but it only grabs the last value. for a basic example the first textbox ,textbox1(0 to 5) array has values of "100, 200, 300, 400, 500, 600" and textbox2(0 to 5) has values of 150, 250, 350, 450, 550, 650" when i run the first form i use the textbox1().values in a calculation "100" the first time the code runs and then "200" the second time etc etc. then when the cnt is done the code finishes and goes to the next form. the calculation in the next code is a bit tricker what i am trying to do is use the Textbox1(0) + textbox2(0) and add them together(not exactly what i am trying to so but shown to simplify) so the first time the code runs it will be "100 + 150" then "200 + 250" etc etc etc until the cnt is complete. The 1st form code runs fine its when the 2nd form runs instead of what I want I get “600 + 150” then “600 + 250” then “600 + 350” so it only using the last value in the textbox1 array. the 1st forms textbox = UFAutoDrwCwMullInpt.TxtbxMullionXSrtPos(I).Value For I = 0 To Cnt MyTranYpos = TxtbxTransomYSrtPos(I).Value MyBayWidVar = UFAutoDrwCwMullInpt.TxtbxMullionXSrtPos(I).Value' without this added it runs but only remembers the value of the last textbox1() ThisDrawing.SetVariable "CMLSTYLE", UFrmAutoDrawCW.TxtBxMLineStyle.Value '<--style name SeedVariables ' Define the 3D multiline points points(0) = LHTOL + CwWid * 1: points(1) = MyTranYpos: points(2) = 0: points(3) = LHTOL + CwWid + MyBayWidVar ' points(4) = points(1): points(5) = 0: ' Create a mline object in model space Set mLineObj_Tran1stRow = ThisDrawing.ModelSpace. _ AddMLine(points) 'ThisDrawing.Application.ZoomAll mLineObj_Tran1stRow.Layer = "0" mLineObj_Tran1stRow.MLineScale = UFrmAutoDrawCW.TxtBxCWWid mLineObj_Tran1stRow.Update Next without this added it runs but only remembers the value of the last textbox1(), when added it says method or data member not found? MyBayWidVar = UFAutoDrwCwMullInpt.TxtbxMullionXSrtPos(I).Value' without this added it runs but only remembers the value of the last textbox1() For I = 0 To Cnt MyTranYpos = TxtbxTransomYSrtPos(I).Value ThisDrawing.SetVariable "CMLSTYLE", UFrmAutoDrawCW.TxtBxMLineStyle.Value '<--style name SeedVariables ' Define the 3D multiline points points(0) = LHTOL + CwWid * 1: points(1) = MyTranYpos: points(2) = 0: points(3) = LHTOL + CwWid + MyBayWidVar ' points(4) = points(1): points(5) = 0: ' Create a mline object in model space Set mLineObj_Tran1stRow = ThisDrawing.ModelSpace. _ AddMLine(points) 'ThisDrawing.Application.ZoomAll mLineObj_Tran1stRow.Layer = "0" mLineObj_Tran1stRow.MLineScale = UFrmAutoDrawCW.TxtBxCWWid mLineObj_Tran1stRow.Update Next i have the following two modules Public LHTOL As Double Public RHTOL As Double Public BTMTOL As Double Public TOPTOL As Double Public CwWid As Double Public StrucOpHght As Double Public StrucOpWid As Double Public MyTranYpos As Double Public TxtbxMullionXSrtPos() As MSForms.TextBox Public MyTotBayWidths As Double Public MyBayWidVar As Double and Sub SeedVariables() LHTOL = UFrmAutoDrawCW.TxtBxTolLH RHTOL = UFrmAutoDrawCW.TxtBxTolRH BTMTOL = UFrmAutoDrawCW.TxtBxTolBtm TOPTOL = UFrmAutoDrawCW.TxtBxTolTop CwWid = UFrmAutoDrawCW.TxtBxCWWid.Value StrucOpHght = UFrmAutoDrawCW.TxtBxSOHght.Value StrucOpWid = UFrmAutoDrawCW.TxtBxSOWid.Value End Sub Quote Link to comment Share on other sites More sharing options...
rocheey Posted September 16, 2008 Share Posted September 16, 2008 god, where to start? hmmm,. you've got an a control array, dimmed as public, in a code module? that should be in the form module, and store the values as an array in a code module. Youve got 2 different code modules; you only need one. You are still referencing (many times) the values in text boxes, from outside the form(s). It appears you are referencing the values in textboxes from other forms - I see the dot qualifier, (which Im assuming means you have the form name in front of the text box) in front of a text box reference. Theres still so much code missing from the post you cant see whats going on. This, again is why you set your code up to be modular - make each individual piece run almost on its own, to test to make sure its running right. I have to assume you are still having a problem with variable SCOPE - you are referencing variables and objects that are not available to other procedures. Again, this is why you set the values of the variables into a public array, from the controls, and stop referencing the values of the controls. You have to be more in depth in your error descriptions: "only remembers the value of the last textbox1()" - what does this mean? they all have the same value? it errors out? Its impossible to reproduce the bugs when only partial code is posted. Again, you've got to make each form module stand on its own - with the only link to be the public variables (not control objects) in the code module. And start sprinkling debug.print statements into your loops - so you can see the status of your variables as they loop thru. Quote Link to comment Share on other sites More sharing options...
comcu Posted September 16, 2008 Author Share Posted September 16, 2008 Rochey, Thank you for the help. Sorry if I wasn’t clear but I added an example of the error The 1st form code runs fine its when the 2nd form runs instead of what I want I get “600 + 150” then “600 + 250” then “600 + 350” so it only using the last value in the textbox1 array. The reason I have a control array dimmed was I was trying to make MyBayWidVar Code Available when the second form runs [code] For I = 0 To Cnt MyTranYpos = TxtbxTransomYSrtPos(I).Value MyBayWidVar = UFAutoDrwCwMullInpt.TxtbxMullionXSrtPos(I).Value' without this added it runs but only remembers the value of the last textbox1() ThisDrawing.SetVariable "CMLSTYLE", UFrmAutoDrawCW.TxtBxMLineStyle.Value '<--style name SeedVariables ' Define the 3D multiline points points(0) = LHTOL + CwWid * 1: points(1) = MyTranYpos: points(2) = 0: points(3) = LHTOL + CwWid + MyBayWidVar ' points(4) = points(1): points(5) = 0: ' Create a mline object in model space Set mLineObj_Tran1stRow = ThisDrawing.ModelSpace. _ AddMLine(points) 'ThisDrawing.Application.ZoomAll mLineObj_Tran1stRow.Layer = "0" mLineObj_Tran1stRow.MLineScale = UFrmAutoDrawCW.TxtBxCWWid mLineObj_Tran1stRow.Update This runs in the form Dim numButtons As Integer: numButtons = TxtBxMullNum.Value ReDim TxtbxMullionXSrtPos(numButtons) 'Dim I As Integer CntMullionQty = numButtons numButtons = numButtons - 3 Cnt = numButtons For I = 0 To numButtons '- 2# ' create a control on the fly Set TxtbxMullionXSrtPos(I) = Me.Controls.Add("Forms.textbox.1", "TxtbxMullionXSrtPos" & LTrim$(Str$(I)), True) ' set its position and size TxtbxMullionXSrtPos(I).Height = 20: TxtbxMullionXSrtPos(I).top = 70 TxtbxMullionXSrtPos(I).Left = 5 + (I * 40) + 5: TxtbxMullionXSrtPos(I).Width = 35 Next I Me.Width = 700 Me.Height = 200 Me.Left = 150 CreateMullionLabels This creates the textboxes, so you are saying I should run this in a module instead? And then add MyBayWidVar = UFAutoDrwCwMullInpt.TxtbxMullionXSrtPos(I).value To the seed variables module? Cheers, Col PS if that isn’t correct and I am misunderstanding I have loaded my project and a drawing, if you have time to look at it. I know it is a lot and If you haven’t got time I appreciate the help you have gave me. The drawing shows what happens when the following has happened UFrmAutoDrawCW has been run Button marked “CREATE SO PERIM & Jamb MULLIONS” has been clicked Button marked “OPEN CNT MULL FORM” has been clicked This opens form “UFAutoDrwCwMullInpt” You click button enter Then “create mullions” Then “”next This opens form “UFAutoDrwCwTranInpt” Then enter Then “Create 1st Row Transom” This is where the error occurs that I described above. ProjAutoDrawCW.zip AutoDrawCW.zip Quote Link to comment Share on other sites More sharing options...
comcu Posted September 16, 2008 Author Share Posted September 16, 2008 Rocheey, I have played about a lot tonight and have cleaned up the code a lot as you suggested. i only have the last form module to do and the problem is nearly solved. i think i should be able to work it out now, thank you very much for your time and help. cheers, col Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.