Results 1 to 7 of 7

Thread: Need some help manipulating a variable in VBA code

  1. #1
    Member
    Join Date
    2007-04
    Posts
    31
    Login to Give a bone
    0

    Default Need some help manipulating a variable in VBA code

    The attached code is almost complete except i have come to a screaming halt so close to the end. The code needs to
    1. insert the block after prompting for two point so that it is inserted according to the rotation of the two points chosen. (refer pdf file attached for example)
    2. I have a variable in the code txtTendonLength which needs to be multiplied by the variable strandmultiply.
    txtTotStrandLength is the result of the variable txtTendonLength being multiplied by variable strandMultiply
    Strandmultiply is the result of selecting 2s,3s or 4s from the userform resulting in strandmultiply =2,3,4
    I would greatly appreciate any help anyone can give. I need to try to get this finalised this week
    Regards
    John
    Attached Files Attached Files

  2. #2
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Need some help manipulating a variable in VBA code

    Where exactly you are having problem? Can you mention specifically?

  3. #3
    Member
    Join Date
    2007-04
    Posts
    31
    Login to Give a bone
    0

    Default Re: Need some help manipulating a variable in VBA code

    i cannot seem to get the strandmultiply part to work and i am having trouble with the insertion of the block. all else seems to work and the block is being created as i want it. the only missing part to the block is the total stand length attribute which is the tendon length multiplied by the number of strands (ie 2 for 2s, 3 for 3s etc)
    john

  4. #4
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Need some help manipulating a variable in VBA code

    Quote Originally Posted by jbortoli
    i cannot seem to get the strandmultiply part to work and i am having trouble with the insertion of the block. all else seems to work and the block is being created as i want it. the only missing part to the block is the total stand length attribute which is the tendon length multiplied by the number of strands (ie 2 for 2s, 3 for 3s etc)
    john
    Here goes some suggestions.

    1. If you want txtTotStrandLength variable to be available across different subroutines/functions, declare it as Public (Otherwise you must write code for calculating it each time a sub/function is called).

    2. Do not multiply a string with a number without having proper conversion. I suggest you to exclude the 's' part from the number of strands as you have clearly mentioned it in the form.

    3. Include maximum code (especially the calculations) in the module and call it from the form events instead of doing it in the form. It will make your code and logic easily understandable.

    4. You have never added / declared txtTotStrandLength as an object in your form/code. That makes the following code completely invalid.
    Code:
     
    varAttributes(intIndex).TextString = txtTotStrandLength.Text
    HTH

  5. #5
    Member
    Join Date
    2007-04
    Posts
    31
    Login to Give a bone
    0

    Default Re: Need some help manipulating a variable in VBA code

    what you are saying makes some sense to me but i am not very experienced and sort of teaching myself as i go. What i achieved here is by shear trial and error so far
    1.when the user selects either 2s, 3s,4s etc from the form the intent is anew variable is to be created at this stage of either 2,3, or 4.
    2. i dont know how i can drop the 's' part and still have the block created with the visible atrribute 2s etc.
    3. you have me stumped here.
    4. noted
    would it be possible for you to say add some code and highlight what you mean or is that too much to ask
    regards john

  6. #6
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Need some help manipulating a variable in VBA code

    Quote Originally Posted by jbortoli
    would it be possible for you to say add some code and highlight what you mean or is that too much to ask
    regards john
    No problems. Let me find some free time to have a look at it. Learning your code will be the most time consuming part.

  7. #7
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Need some help manipulating a variable in VBA code

    Quote Originally Posted by jbortoli
    would it be possible for you to say add some code and highlight what you mean or is that too much to ask
    regards john
    Done. I have commented wherever I made changes. I have added the following function to isolate the total strand length calculation
    Code:
     
    Public Function getTotalStrandLength(ByVal strTendonLength As String, ByVal strNumOfStrands As String) As Double
    Dim dTLength As Double
    Dim iNumOfStrands As Integer
    dTLength = CDbl(strTendonLength)
    iNumOfStrands = CInt(Replace(strNumOfStrands, "s", "", , , vbTextCompare))
    getTotalStrandLength = dTLength * iNumOfStrands
    End Function
    If you don't understand any part of modifications, feel free to ask us.

    HTH
    Attached Files Attached Files

Similar Threads

  1. Replies: 5
    Last Post: 2014-08-06, 09:33 PM
  2. Manipulating layouts *
    By elias.arrud in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2013-01-17, 05:05 AM
  3. Help with manipulating drawings please!
    By dfuehrer in forum VBA/COM Interop
    Replies: 8
    Last Post: 2008-05-16, 05:59 PM
  4. Manipulating points in a list
    By noadea in forum AutoLISP
    Replies: 7
    Last Post: 2007-04-13, 04:04 AM
  5. Manipulating OLE Objects
    By zoomharis in forum VBA/COM Interop
    Replies: 11
    Last Post: 2006-04-06, 08:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •