Need correct syntax for VB code in Visual Studio 2015 for Space Automation Pro

parkerbelt

Active Member
Joined
May 23, 2014
Messages
377
I'm trying to write a program for Space Planning - Space Automation Pro and I can't seem to get the syntax correct to do what I want to do. Here is the code that I'm trying:

Code:
 For Each Posi As Space.Position In SpacePlanning.ForPositions(WhereCondition:=(SpaceProductFields.Desc21, ""))

                'SpacePlanning.SelectPosition()
                SpacePlanning.CutToClipboard()
                DeleteCount = DeleteCount + 1


            Next

I'm trying to check the Description 21 field to see if it is blank and if so, delete the position from the Planogram.
There aren't any resources to look for Space Automation Pro syntax, but I thought that since this code is Visual Basic, someone on here might be able to tell me how to correct my syntax.

Visual Studio doesn't like my comma after Desc21 and the first quote has the red squiggly line under it too. When I run my cursor over the comma, intelisense says ')' expected and when I run the cursor over the first quote, it says Named argument expected.

I've tried putting in a ) and tried putting in Equals "" and a number of other things, but can't get the syntax just right.
Anyone have a clue what I should do?
Thanks!

Here's what the help section shows for Syntax:
[h=2]ForPositions[/h]This loop performs actions for all positions on the active planogram. You can use the WhereCondition parameter to identify specific positions to be processed by the commands in the loop.
Note: If you include commands that refer to the ProductKey in this loop and multiple positions of the selected products exist on the active planogram, care should be taken to ensure the proper positions are modified by the commands.
Syntax
For Each Var as Space.Position In SpacePlanning.ForPositions(WhereCondition as String)
Next
Var
Var is a variable of type Space.Position.
WhereCondition (optional)
String. For applicable loops, specifies the criteria used to filter the objects that are processed by commands in the loop. For the SelectObjects and DeselectObjects commands, specifies the criteria used to filter the objects that are selected or deselected.
Example: Modify positions on a planogram
Classic style scripting
SpacePlanning.OpenProjectFile("C:\Program Files (x86)\JDA\Intactix\Samples\Space Planning Planograms\Sample - Coffee Makers.psa")
For Each Posi As Space.Position In SpacePlanning.ForPositions("X = 0")
Posi.SetPositionField(SpacePositionFields.Angle, 10)
Next
Instance style scripting
Dim SpProj As Space.Project
Dim SpPlano As Space.Planogram
SpProj = SpacePlanning.OpenProjectFile("C:\Program Files (x86)\JDA\Intactix\Samples\Space Planning Planograms\Sample - Coffee Makers.psa")
SpPlano = SpProj.SetActivePlanogram(0)
For Each Posi As Space.Position In SpPlano.Positions()
Posi.SetPositionField(SpacePositionFields.Angle, 10)
Next
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I just tried this:
Code:
For Each Posi As Space.Position In SpacePlanning.ForPositions(WhereCondition:=SpaceProductFields.Desc21 = "")

And I got this error message back at run-time:
Exception Unhandled : Conversion from string "" to type 'Double' is not valid.
 
Upvote 0
I tried this:
Code:
For Each Posi As Space.Position In SpacePlanning.ForPositions(WhereCondition:=SpaceProductFields.Desc21 = Nothing)
and I got this error message back at run-time:
Exception Unhandled : Value cannot be null.
Parameter name: Value cannot be null.
Parameter name: argument
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top