XIJIANGWOO Posted October 11, 2009 Posted October 11, 2009 Hello again everyone. I'm struggling withi coming up with a way to create an array based on the number entered into a textbox. The maximum array is 6 columns and 3 rows. For example: If 7 is entered into the text box, I would like the result to be 3 columns with the last column containing only 1 object on the 1 row. What is the fastest and simplist way to accomplish this? As always , any help is greatly appreciated ! Here is my code: Sub ThreeRowArray() On Error GoTo errorhandler blockname = "objButton" insertionPnt(0) = -89.5915: insertionPnt(1) = 0: insertionPnt(2) = 0 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, blockname, 1#, -1#, 1#, 0) '------------------------------------- Dim aEntity As AcadEntity Set aEntity = blockRefObj 'Define the rectangular array Dim NumberofLevels, NumberofRows, numberOfColumns As Double Dim DistanceBtwnLvls, DistanceBtwnRows, DistanceBtwnColumns As Double Dim buttonCount As Integer NumberofLevels = 1 'Enter a value for the amount of Levels in the array ' NumberofRows = 3 '3 'Enter a Value for the amount of Rows 'numberOfColumns = 7 'Enter a Value for the amount of Columns DistanceBtwnLvls = -50 'Enter a Value for the distance between Levels DistanceBtwnRows = 86 'Enter a Value for the distance between Rows DistanceBtwnColumns = -40 'Enter a Value for the distance between Columns ' Create the array of objects Dim retObj As Variant retObj = aEntity.ArrayRectangular(NumberofRows, numberOfColumns, NumberofLevels, DistanceBtwnRows, DistanceBtwnColumns, DistanceBtwnLvls) 'Array is created ThisDrawing.Regen acAllViewports ThisDrawing.Application.ZoomExtents Exit Sub errorhandler: End Sub Quote
XIJIANGWOO Posted October 13, 2009 Author Posted October 13, 2009 I've been looking at redim. I am really green at VBA. Quote
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.