|
-
May 10th, 2007, 02:10 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Array Problem
Hi,
I have the following definition
Code:
Dim nMembers As Int32()
ReDim nMembers(6)
nMembers(1) = oStd.Geometry.AddBeam(nNodes(1), nNodes(2))
nMembers(2) = oStd.Geometry.AddBeam(nNodes(2), nNodes(3))
nMembers(3) = oStd.Geometry.AddBeam(nNodes(3), nNodes(4))
nMembers(4) = oStd.Geometry.AddBeam(nNodes(4), nNodes(5))
nMembers(5) = oStd.Geometry.AddBeam(nNodes(5), nNodes(6))
nMembers(6) = oStd.Geometry.AddBeam(nNodes(6), nNodes(7))
Dim omembList As Object
omembList = nMembers
oStd.Design.AssignDesignParameter(refBrief, "FYLD", "345000", omembList)
The Code
Code:
oStd.Design.AssignDesignParameter(refBrief, "FYLD", "345000", omembList)
gives me the following output
Where as desired output is
it should be MEMB 1 to 6 instead of MEMB 0 to 6
Will be thankful for any feedback
Last edited by surya; May 10th, 2007 at 02:22 AM.
-
May 10th, 2007, 02:28 AM
#2
Re: [2005] Array Problem
.NET arrays are zero-based. By doing this:You are creating an array with 7 elements at indexes 0 to 6. If you want an array with 6 elements then you would have to do this:and set the elements at indexes 0 to 5. You would, of course, have to allow for the offset when creating your output.
If the fact that you need to specify the upper bound rather than the length when creating an array confuses you then I suggest that you make a habit of creating arrays using the length - 1, e.g.
-
May 10th, 2007, 02:36 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Array Problem
Hello jmcilhinney,
Many thanks for your prompt response.
Is there a way to set the index of an array to start with 1 instead of 0.
thanks
-
May 10th, 2007, 02:38 AM
#4
Re: [2005] Array Problem
Is there a way to set the index of an array to start with 1 instead of 0.
I think that it is not good, If you want to avoid the zero position then simple do not use it and put a blank value there.
But it is not good programming.
Last edited by shakti5385; May 10th, 2007 at 03:03 AM.
-
May 10th, 2007, 02:46 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Array Problem
Hello Shakti,
You are probably right!
I remember setting the index to 1 in VB6.0, just wondering if there is some way of achieving the same in VB.Net
-
May 10th, 2007, 02:51 AM
#6
Re: [2005] Array Problem
There is one way but I wouldn't recommend it because you end up with an Array object rather than a typed array:
vb Code:
Dim arr As Array = Array.CreateInstance(GetType(Integer), _
New Integer() {6}, _
New Integer() {1})
Unless you're unable to change the implementation of this AssignDesignParameter method then I suggest that you code "properly" and use zero-based arrays and account for the fact whenever using indexes.
-
May 10th, 2007, 02:59 AM
#7
Thread Starter
Hyperactive Member
Re: [2005] Array Problem
I will change my code to 0 index and revert back shortly..
thanks again...
-
May 10th, 2007, 03:08 AM
#8
Thread Starter
Hyperactive Member
Re: [2005] Array Problem
Ok, Was able to set the index to 0 and recode.
Many for your valuable inputs...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|