AnsweredAssumed Answered

Power sign (^) and 'continue' in loops

Question asked by Peter Brinkhuis on Nov 25, 2015
Latest reply on Nov 28, 2015 by Peter Brinkhuis

Hi guys,

 

I'm trying to do the simplest thing, and it seems like Solidworks doesn't support it even though VBA does.

Sub main()

Dim swApp As Object

Set swApp = Application.SldWorks

 

 

Dim i As Double

i= i^ 2

 

 

End Sub

This line gives me a syntax error because of the power symbol. I've seen the Microsoft VBA documentation and it's supported of course, it's even in the Solidworks help. The only problem is that it doesn't work. Any ideas? The above is a simplification, my actual line of code is lDblScaleLeft = lArrScaleFactors(j+1)*10^i 

 

My second question is regarding using 'continue' in do while and while loops. It seems that it is not supported, even when I follow the guidelines. The little bit of code should go straight from 5 to 9, but again I get a syntax error, now on the continue line.

 

 

 

Sub main()

Dim swApp As Object

Set swApp = Application.SldWorks

 

 

Dim i As Integer

i = 0

Do While i < 10

    MsgBox ( i)

    If i = 5 Then

        i = 9

        continue do

    End If

    i = i + 1

Loop

End Sub

 

Some documentation on the Do loop by microsoft here.

 

What am I doing wrong?

Outcomes