Method Help PLEASE!

Here’s what I currently have, and what it produces.


StringBuilder desc = new StringBuilder();

desc.AppendLine(Inputs.cmbBodyType.Value + “-”

  • Inputs.txtHRackQuoteDesc.Value + “-” + Inputs.txtCompressorQuoteDesc.Value + “-” + Inputs.txtDrawerUnitsQuoteDesc.Value + “-” + Inputs.txtGpsQuoteDesc.Value + “-” + Inputs.txtFireExtQuoteDesc.Value);
    desc.AppendLine();
    desc.AppendLine(“Options:”);
    desc.AppendLine();

Inputs.edtPartDesc.Value = desc.ToString();
It’s currently running all of the “options” back to back, right behind the BodyType. I want the cmbBodyType (U7) to be on one line, and all of the Inputs.txt…QuoteDesc.Value data to be on separate lines, AFTER the “Options” Label.

In the following order:
Inputs.txtCompressorQuoteDesc.Value
Inputs.txtCranesQuoteDesc.Value
Inputs.txtFrontEndReplaceQuoteDesc.Value
Inputs.txtHRackQuoteDesc.Value
Inputs.txtGpsQuoteDesc.Value
Inputs.txtFireExtQuoteDesc.Value
Inputs.txtDrawerUnitsQuoteDesc.Value

My part numbering Method is doing the same thing


I don’t hyave a problem with the inputs running back to back, but I want some type of seperation between the inputs. It’s very hard to read.
The inputs are:
Inputs.cmbCompressor.Value
Inputs.cmbCranes.Value
Inputs.cmbFrontEndReplace.Value
Inputs.cmbHRack.Value
Inputs.cmbGps.Value
Inputs.cmbFireExt.Value
Inputs.cmbDrawerUnits.Value

any suggestions would greatly be appreciated!

So AppendLine() is not creating an empty line between inputs and “options”?

Well typed this without any way to check syntax but I think this is what you are aiming for…

StringBuilder desc = new StringBuilder();
desc.AppendLine(“Options:”);
desc.AppendFormat("\r\n- {0}\r\n- {1}\r\n- {2}\r\n- {3}\r\n- {4}\r\n- {5}\r\n",Inputs.cmbBodyType.Value, Inputs.txtHRackQuoteDesc.Value,Inputs.txtCompressorQuoteDesc.Value,Inputs.txtDrawerUnitsQuoteDesc.Value, Inputs.txtGpsQuoteDesc.Value, Inputs.txtFireExtQuoteDesc.Value);
Inputs.edtPartDesc.Value = desc.ToString();

I’m getting syntax errors!

Correct!

Use Environment.NewLine to add a line break in a string.

string s = "";
string s1 = "Hello";
string s2 = "World!";
// don't use s = s1 + "\n" + s2";
s= s1 + Environment.NewLine + s2;

that yields

Hello
World!

I understand your answer, but my skill level doesn’t match it…based on the code provided by Evan Purdy, where EXACTLY do I place that?

That’s not the issue with my code example anyway, the problem is the fancy quote marks, they should be the normal ones " not “

Environment.NewLine is just a string containing “\r\n” for non-Unix platforms, or a string containing “\n” for Unix platforms. Good practice for cross platform code but not needed in this case.

2 Likes

I suppose this would be a “better” version:

StringBuilder desc = new StringBuilder();
desc.AppendLine("Options:");
desc.AppendFormat("\{0}- {1}{0}- {2}{0}- {3}{0}- {4}{0}- {5}{0}- {6}{0}", Environment.NewLine,Inputs.cmbBodyType.Value, Inputs.txtHRackQuoteDesc.Value,Inputs.txtCompressorQuoteDesc.Value,Inputs.txtDrawerUnitsQuoteDesc.Value, Inputs.txtGpsQuoteDesc.Value, Inputs.txtFireExtQuoteDesc.Value);
Inputs.edtPartDesc.Value = desc.ToString();

I’m old school (really old school), the ability to join strings with an operator is still weird to me. And I’ve never used the StringBuilder type.

I still have to fight the urge to use strcat() :wink:

I like using string interpolation to build strings, but Epicor doesn’t support recent enough version of C# last time I tried.

1 Like

I have seen “type?” declarations now allowed in Epicor Functions. This is great news since I’ve always wanted to write a Catholic dating app (NotBeforeMarriage.com is available) but until now I’ve never been able to mark the marriage variable as nullable.

:thinking:

4 Likes

Make sure you make the marriage relationship many-to-one and well as one-to-one so you can re-brand it as a Mormon dating app later.

@Townes69 We derailed your topic a little, ever get this working?