Creating a combobox list via UD method

Hi all,

I am using a UD method to create a list in a combobox in a configurator. The ipLength is always divisible by 75 and when the ‘BlankType’ is ‘B’ the maximum blanking length should be the ipLength - 75.
The code below works fine until I want to take 75 off the ipLength for ‘BlankType’ ‘B’, then I get an error telling me the input string is not of the correct format. The list is still created correctly however. Can anyone advise me as to what is causing my problem?
Much appreciated.
Adrian.

string opListItems = "";
int length = 0;
	if (ipLength != "")
		{
		length = System.Convert.ToInt32(ipLength);
		if (Inputs.cmbBlankType.Value == "B")
		{
			length = length - 75;
		}	
		do
		{
		  opListItems += length.ToString() + "~";
		  length = length - 75;
		} 
		while (length > 0);
		}
return opListItems;

I assume ipLength is a string, right? Try using the Parse or TryParse methods when converting it to an int instead of trying a direct Convert.ToInt32

2 Likes

Hi @Aaron_Moreng,

Yes it ipLength is a value from a combobox on the configurator page. I’m working through the examples in the link you sent but no luck yet.
The exception comes right before the ‘return’ line, but like I said it still creates the correct list. Is there a way to not show the exception, if I can’t get it working without it?
Best regards
Adrian.

Same exception? Can you provide the full exception detail?

Yes the same one;