EnumerateValues

Jeffrey Roark

EnumerateValues

I have some VBA code that has been used for a long time.  Resently VBA has been upgraded from VBA6.0 to VBA6.5.  The same code now fails.  It does work as CATScript, but have to find a way to make it work in VBA.

Need to be able to get Multiple values from a Parameter and populate a VBA Listbox.

Any ideas?

------------------------------------------------------

Sub CATMAIN()

Dim partDocument1 As PartDocument

Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part

Set part1 = partDocument1.Part

Dim parameters1 As Parameters

Set parameters1 = part1.Parameters

Dim strParam1 'As StrParam

'---CATPart has String Paramter with multilple values named String ---'

Set strParam1 = parameters1.Item("String")

Dim ParamValues() As Variant

ReDim ParamValues(strParam1.GetEnumerateValuesSize() - 1)

strParam1.GetEnumerateValues (ParamValues)

For i = 0 To strParam1.GetEnumerateValuesSize() - 1

    MsgBox ParamValues(i)

Next

End Sub

------------------------------------------------------

Thanks

Jeffrey Roark

RE: EnumerateValues
(in response to Jeffrey Roark)

Found the answer : -)

Thanks google!

http://my.safaribooksonline.com/book/programming/vbscript/9780071800020/8dot-featured-object-classes/ch8_179_html

Sub CATMAIN()

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim parameters1 As Parameters
Set parameters1 = part1.Parameters

Dim strParam1 'As StrParam
Set strParam1 = parameters1.Item("String")

'------ Few changes here ------

cnt = strParam1.GetEnumerateValuesSize

Dim ParamValues() As Variant

ReDim ParamValues(cnt)
strParam1.GetEnumerateValues ParamValues

        For i = 0 To cnt - 1
            MsgBox ParamValues(i)
        Next

'------ Few changes here ------

End Sub

Thanks!

Alexandre Desaulniers

RE: EnumerateValues
(in response to Jeffrey Roark)

Google and Little Cthulhu are you best friends ... (Order doesn't represent the preference)

Mike Dubya

RE: EnumerateValues
(in response to Jeffrey Roark)

Sorry to revive a dead thread but this has raised a question for me...

What is the difference between a StrParam array (at least I'm assuming it's an array) and the Variant array?  Isn't it redundant to convert the strParam1 to ParamValues ?