Do While statement case

Do While statement case

danijel.radenkovic
Collaborator Collaborator
1,838 Views
2 Replies
Message 1 of 3

Do While statement case

danijel.radenkovic
Collaborator
Collaborator

Hello,

I have a little problem to move from iLogic code to VBA code.

 

Here is the statement which I have to convert in VBA code:

 

If RealValue < TargetValue Then
	
	While RealValue < TargetValue
	pDistance = pDistance - .1
	RuleParametersOutput()
	InventorVb.DocumentUpdate(True)
	End While

ElseIf RealValue > TargetValue Then
	While RealValue > TargetValue
	pDistance = pDistance + .1
	RuleParametersOutput()
	InventorVb.DocumentUpdate(True)
	End While
End If

Any help is very appreciated.

 

Danijel

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Accepted solutions (1)
1,839 Views
2 Replies
Replies (2)
Message 2 of 3

NachoShaw
Advisor
Advisor
Accepted solution

Hi

 

Based on your code, I would typically approach it this way however, I don't know what your code is doing or whether RealValue is updating during this particular code section. If its not, then it 'could' loop indefinitely as you are telling to continue in a loop until RealValue < TargetValue

 

Select Case RealValue
    Case < TargetValue
        Do While RealValue =< TargetValue
            pDistance = pDistance - .1
            RuleParametersOutput()
            InventorVb.DocumentUpdate(True)
        Loop

    Case > TargetValue
        Do While RealValue >= TargetValue
            pDistance = pDistance + .1
            RuleParametersOutput()
            InventorVb.DocumentUpdate(True)
        Loop
End Select

Hope that helps

 

 

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 3 of 3

danijel.radenkovic
Collaborator
Collaborator

@nmjshaw150 wrote:

Hi

 

Based on your code, I would typically approach it this way however, I don't know what your code is doing or whether RealValue is updating during this particular code section. If its not, then it 'could' loop indefinitely as you are telling to continue in a loop until RealValue < TargetValue

 

Select Case RealValue
    Case < TargetValue
        Do While RealValue =< TargetValue
            pDistance = pDistance - .1
            RuleParametersOutput()
            InventorVb.DocumentUpdate(True)
        Loop

    Case > TargetValue
        Do While RealValue >= TargetValue
            pDistance = pDistance + .1
            RuleParametersOutput()
            InventorVb.DocumentUpdate(True)
        Loop
End Select

Hope that helps

 

 

 

Nacho


Hi Nacho,

That is what I was trying to do. To convert vb.net statement to vba statement. In other words:

While
End While

'into:

Do While
Loop

Code between was not a problem. Differences between vb.net code and vba code can be a problem sometimes.

Thank you very much for the help!

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes