0
Good afternoon!
I’m having doubts about implementing an algorithm that can calculate the heat flow based on the formulas:
q=ΔT/Rt
ΔT=Temperatureinitial-Temperaturefinal
Rt(Thermal resistance)=L(Thickness)/K(contutivity)*A(area -m²)
All have textbox and would like to create a logical condition that if a field not filled the program inform in the textbox the calculation performed. Follow an example I did but did not turn the second condition.
//calcula q=ΔT/Rt
if (txt_Resist.Text.Trim() != null && delta_temp.Text.Trim() != null)
{
decimal q;
q = Fluxo_Calor(Convert.ToDecimal(delta_temp.Text.ToString()), Convert.ToDecimal(txt_Resist.Text.ToString()));
//informa o valor de q no textbox do resultado
txtResultado.Text = q.ToString();
}
//Calcula Q=(Temperaturaincial-Temperaturafinal)/Rt
else if (txt_Resist.Text.Trim() != null && txt_delta1.Text.Trim() != null && txt_delta2.Text.Trim() != null)
{
decimal delta, q;
delta = Deltatemperatura(Convert.ToDecimal(txt_delta1.Text.ToString()), Convert.ToDecimal(txt_delta2.Text.ToString()));
//Retorna o valor de delta no textbox
delta_temp.Text = delta.ToString();
//informa o valor de q no textbox do resultado
q = Fluxo_Calor(delta, Convert.ToDecimal(txt_Resist.Text.ToString()));
txtResultado.Text = q.ToString();}
Apparently the image error is some problem in converting the string to decimal. The value of this field that you are trying to convert to decimal has only numbers, "." or ","?
– Cleidson_eng
Could put the code of the function Fluxo_heat()
– Cassio Alves
You could use the form txt_Resist.Text.Trim() != null (which is wrong, because it will always be an empty string, not a null) by ! string.Isnullorwhitespace(txt_Resist.Text). Also the Text property does not need . Tostring() after it, as it is already a string.
– Grupo CDS Informática