This VB code is not properly organized. I make some assumption to complete it.
1) In absence
if we found an
elseif. I assumed it as
if.
2) The Data Type and Value of RawADC is not defined. I defined it as
double and assigned 100.
In c# text to numeric conversion is not that much simple, you have to define it as double, decimal, and integer etc. In this case, I defined it as double. You are collecting values from text boxes, there are issues to handle blank and non-numeric values. I did not go for that.
Finally, the converted code will be like it
{
double slop1, intercept1;
double RawADC = 100;
if (RawADC >= Convert.ToDouble(TextBoxRawVal2.Text) & RawADC < Convert.ToDouble(TextBoxRawVal3.Text))
{
slop1 = (Convert.ToDouble(TextBoxRealWeight3.Text) - Convert.ToDouble(TextBoxRealWeight2.Text)) / (Convert.ToDouble(TextBoxRawVal3.Text) - Convert.ToDouble(TextBoxRawVal2.Text));
intercept1 = Convert.ToDouble(TextBoxRealWeight3.Text) - slop1 * Convert.ToDouble(TextBoxRawVal3.Text);
txtSlop1.Text = slop1.ToString();
txtIntercept1.Text = intercept1.ToString();
}
}
I implemented this code on .Net 6.