c# - Textbox entry giving errors -
i have 4 text boxes.
in first textbox doubleclicking , opening child form.
there displaying names , values.
selecting 1 name in form , name coming first form first text box , next text box value coming.
next want take input using third text box , caliculations, display result in fourth textbox(readonly one).
giving error.
made mistake.
//take values child form: private void datagridview1_celldoubleclick(object sender, datagridviewcelleventargs e) { form8.code = datagridview1.currentrow.cells[0].value.tostring(); form8.name = datagridview1.currentrow.cells[1].value.tostring(); form8.fiel= datagridview1.currentrow.cells[6].value.tostring(); form8.measure= datagridview1.currentrow.cells[2].value.tostring(); //my main form store values: boxname.text = name; if (boxname.text == "") { messagebox.show("empty name"); } else { boxbprice.text = fiel; double qty = convert.todouble(boxqty.text);//taking quanty input }
where did mistake. giving error
"input string not in currect format"
"input string not in currect format"
the error means string
you're trying parse doesn't contain double value.
- ensure field holds input data valid text representation of
double
value (in correct format). - you use
double.tryparse
prevent error, you'd need debug program , see actual value ofconvert.todouble(boxqty.text);
@ run time.
example of using tryparse:
double number; if (double.tryparse(boxqty.text, out number)){ // value of number }
Comments
Post a Comment