Booney440 Booney440 - 5 months ago 41
C# Question

Facing a Round up TexBox not working C#

TextBox4 will not round up, can you help?

var start_time = textBox6.Text;
var trailer_count = Convert.ToInt32(textBox4.Text);
var minutes_apart = Convert.ToDouble(textBox5.Text);
var trailers = new List<Trailer__Time>();
for (var i = 0; i < trailer_count; i++) // CHANGED FROM 1 TO 0

string str1 = "500";
string str2 = "32";
int value = (int)Math.Ceiling( Convert.ToDouble(str1) / Convert.ToDouble(str2)); //16

You have to first convert strings to double or decimal values and then pass this result to Math.Ceailing with explicit type cast to int. Now you can convert this value variable to string or other datatype according to your requirement.