Your Products have been synced, click here to refresh
Public Sub VarSet() [B]Dim PCDPart,Cmds,Cmd As Object PCDPart = PCDApp.ActivePartProgram Cmds = PCDPart.Commands[/B] For Each Cmd In [B][COLOR=#FF0000]Cmds [/COLOR][/B] If [B]Cmd.Type[/B] = "Assignment" And Cmd.GetText(DEST_EXPR, 0) = "JOBNO" Then retval = Cmd.PutText("1234", SRC_EXPR, 0) End If Next Cmd endForm() End Sub
Thanks for the help Don and Rploughe, I think the problem lies with VB.Net and/or the 2014 PCDLRN Object Library.
It still gives me that same error on the For Each Cmd in Cmds
For I = 1 to Cmds.Count Set Cmd = Cmds(I) <do something with Cmd> Next I
Cmd = Cmds[1] while ??some expression testing for not null which I don't remember how it should look?? <do something with cmd> Cmd = Cmd.Next end while
I do know that VB.Net has an issue with collections, they are pretty much not recognized. You would need to use something more like
For each Cmd in Cmds.Count
'Set Program Variables Public Sub VarSet() Dim PCDApp, PCDPartPrograms, PCDPartProgram Dim PCDCommands, PCDCommand As Object Dim Shift As String PCDApp = CreateObject("PCDLRN.Application") PCDPartProgram = PCDApp.ActivePartProgram PCDCommands = PCDPartProgram.Commands PCDPartProgram = PCDApp.ActivePartProgram Cmds = PCDPartProgram.Commands For i = 1 To Cmds.Count Cmd = Cmds.Item(i) If Cmd.Type = "Assignment" And Cmd.GetText(DEST_EXPR, 0) = "JOBNO" Then retval = Cmd.PutText(TextBox3.Text, SRC_EXPR, 0) End If Next i endForm() End Sub
Sorry for the late response I was out for a few days.
This is how the code sits now:
'Set Program Variables Public Sub VarSet() Dim PCDApp, PCDPartPrograms, PCDPartProgram Dim PCDCommands, PCDCommand As Object Dim Shift As String PCDApp = CreateObject("PCDLRN.Application") PCDPartProgram = PCDApp.ActivePartProgram PCDCommands = PCDPartProgram.Commands PCDPartProgram = PCDApp.ActivePartProgram Cmds = PCDPartProgram.Commands For i = 1 To Cmds.Count Cmd = Cmds.Item(i) If Cmd.Type = "Assignment" And Cmd.GetText(DEST_EXPR, 0) = "JOBNO" Then retval = Cmd.PutText(TextBox3.Text, SRC_EXPR, 0) End If Next i endForm() End Sub
I am still getting errors on retval, DEST_EXPR, SRC_EXPR saying they are not declared.
Sorry for the late response I was out for a few days.
This is how the code sits now:
'Set Program Variables Public Sub VarSet() Dim PCDApp, PCDPartPrograms, PCDPartProgram Dim PCDCommands, PCDCommand As Object Dim Shift As String PCDApp = CreateObject("PCDLRN.Application") PCDPartProgram = PCDApp.ActivePartProgram PCDCommands = PCDPartProgram.Commands PCDPartProgram = PCDApp.ActivePartProgram Cmds = PCDPartProgram.Commands For i = 1 To Cmds.Count Cmd = Cmds.Item(i) If Cmd.Type = "Assignment" And Cmd.GetText(DEST_EXPR, 0) = "JOBNO" Then retval = Cmd.PutText(TextBox3.Text, SRC_EXPR, 0) End If Next i endForm() End Sub
I am still getting errors on retval, DEST_EXPR, SRC_EXPR saying they are not declared.
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |