Variablenbezeichnung in einer For-Next-Programmierung ändern / Changing variables in a For-Next programming

Variablenbezeichnung in einer For-Next-Programmierung ändern / Changing variables in a For-Next programming

A_Hoe_
Participant Participant
800 Views
8 Replies
Message 1 of 9

Variablenbezeichnung in einer For-Next-Programmierung ändern / Changing variables in a For-Next programming

A_Hoe_
Participant
Participant

In einer For-Next-Programmierung sollen die Variablenbezeichnungen nach jedem Durchgang automatisch hochgezählt werden.

 

Beispiel:

 

For i = 1 to 5

  Variablennamen & i = ....

Next

 

Wie heisst der Code um in die Variablenbezeichnung den Wert i einzubinden?

 

 

In For-Next programming, the variable names should be automatically incremented after each pass.

 

Example:

 

For i = 1 to 5

  Variable name & i = ....

Next

 

What is the code to include the value i in the variable name?

0 Likes
801 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor

Dim i as integer = 1
for i = 1 to 5
i = i+1
next

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 9

A_Hoe_
Participant
Participant

Hi Arthur,

 

thanks for the feedback, but unfortunately that doesn't answer my question.

I would like to include the variable i in the names of other variables, i.e. change the variable names after each run.

0 Likes
Message 4 of 9

bradeneuropeArthur
Mentor
Mentor
Do you have an example?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 9

d_eckel
Contributor
Contributor

Hallo, was genau hast du vor? Könnte ein "for each in" etwas sein?

Ansonsten würde mir eine Array List einfallen, bei der du dann den jeweiligen Eintrag über Variablennamen(i) ansprechen könntest (wenn ich mich nicht irre).

Grüße

David

0 Likes
Message 6 of 9

A_Hoe_
Participant
Participant

Hallo!

 

Ich habe 5 Variablen (REV1, 2, 3, 4, 5).

Diese möchte ich der Reihe nach über eine Formel ändern.

Wie muss ich die Variable anlegen, damit sich der Name nach jedem Durchgang automatisch ändert.

Ich hatte sowas schon mal programmiert, bekomme es aber nicht mehr zusammen.

Es müsste, glaube ich, so ungefähr aussehen. 

 

Dim REV() As Integer

Dim i As Integer

 

For i = 1 to 5

  REV(i) = .....

Next

 

Bekomme aber immer die Meldung  "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt"

0 Likes
Message 7 of 9

m_baczewski
Advocate
Advocate

Hello,

 

Try this code if you have defined a user parameters in document.

2023-12-12_09h40_05.png

For i As Integer = 1 To 4
	Parameter("param" + i.ToString) = i+1
Next

 

Or use this code if you are working on variables in Ilogic. I defined list with parameters that you want and change values in each iteration.

 

Dim variable1 As Integer=1
Dim variable2 As Integer=2
Dim variable3 As Integer=3
Dim variable4 As Integer=4
Dim variable5 As Integer = 5

Dim variableList As New List(Of Integer)

variableList.Add(variable1)
variableList.Add(variable2)
variableList.Add(variable3)
variableList.Add(variable4)
variableList.Add(variable5)

Dim j As Integer = 10

For Each variable In variableList
	
	variable = 10 + j
	j += 25
	Logger.Info(variable)
Next

 

0 Likes
Message 8 of 9

d_eckel
Contributor
Contributor

So etwas in der Art?

 

Dim Rev As New ArrayList

' Lege 5 Einträge an
For i = 1 To 5
	Rev.Add("")
Next

' mache was mit den Werten
For i = 1 To Rev.Count
  Rev(i) = i
Next
0 Likes
Message 9 of 9

m_baczewski
Advocate
Advocate

Here you have the code in two variants, choose your case.

 

Dim Rev As New ArrayList
' Lege 5 Einträge an
For i = 1 To 5
	Rev.Add(i)
Next
' mache was mit den Werten
For j = 0 To Rev.Count - 1
	'do something assing a value to variable
	Logger.Info(Rev(j))
Next

'Rev=[1,2,3,4,5]
'iteration Rev[0] = 1
'iteration Rev[1] = 2
'iteration Rev[2] = 3
'iteration Rev[3] = 4
'iteration Rev[4] = 5
Dim Revision As New ArrayList ' Lege 5 Einträge an For i = 0 To 5 Revision.Add(i) Next ' mache was mit den Werten For j = 1 To Revision.Count - 1 'do something assing a value to variable Logger.Info(Revision(j)) Next 'Rev=[0,1,2,3,4,5] 'iteration Rev[0] = 0 'iteration Rev[1] = 1 'iteration Rev[2] = 2 'iteration Rev[3] = 3 'iteration Rev[4] = 4 'iteration Rev[5] = 5

 

0 Likes