Input string was not in a correct format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've tried many conversions to get the values to be accepted, but none are
working and the subject error message is returned for Parse and ToInt32. I
haven't figured out what "format" is wrong. I'm attempting to modify the
Location property of a text and picture box at runtime. The assignment is
like this:

this.memoEdit1.Location = new Point(txtX,500); //args = Point(int, int)

Any ideas what I'm not "formatting?"

Thanks,

E
 
What exactly it txtX? Is it a textbox? In that case, you'd want
something like
int x = Convert.ToInt32(txtX.Text);

I've tried many conversions to get the values to be accepted, but
none are working and the subject error message is returned for Parse
and ToInt32. I haven't figured out what "format" is wrong. I'm
attempting to modify the Location property of a text and picture box
at runtime. The assignment is like this:

this.memoEdit1.Location = new Point(txtX,500); //args =
Point(int, int)

Any ideas what I'm not "formatting?"

Thanks,

E

--
Truth,
James Curran [MVP]
www.NJTheater.com (Professional)
www.NovelTheory.com (Personal)
MVP = Where your high-priced consultant goes for free answers
 
Yes, txtX is a bound text box. The conversion doesn't work. Here's the test
that fails, the first line is highlighted, though I thing the following is
failing.
int txtX = Convert.ToInt32(textBox1.Text);
this.memoEdit1.Location = new Point(txtX,500);

I've also tried to create array/object lists and enum them into the control
and it didn't like that either. There has to be a way to get the int values
from SQL server into the application. The re-write is going to ASP when it
comes back around.

Thanks for the reply.

E
 
Esteban404 said:
Yes, txtX is a bound text box. The conversion doesn't work. Here's
the test that fails, the first line is highlighted, though I thing
the following is failing.
int txtX = Convert.ToInt32(textBox1.Text);
this.memoEdit1.Location = new Point(txtX,500);

Hold it. In your first sentence you say txtX is a text box. Then, in
the code example you give, you define txtX as an int, and now start
referring to a new object, textBox1.

My my example, I defined a brand-new varaible called, x, which is the
value of the text in the textbox txtX.
int x = Convert.ToInt32(txtX.Text);
this.memoEdit1.Location = new Point(x,500);

If that does not work, then the value in the textbox is wrong (not a
number).
 
Hold it. In your first sentence you say txtX is a text box.
I see my communication problem. ;-) textBox1 is the text box (bound to the
datasource from SQL server), txtX is declared int for the purpose of this
test. In any case, converting the value from the bound textBox to int is not
accepted by the new Point() method. I can define a brand new variable, but it
hasn't mattered. I think it'll have to be a switch case process if I can't
get the bound data to work.

Thanks for the reply.

E.
 
It will not convert the value in the text box. Error every time that it's
"not in the correct format." The value shown on the form, however, is
correct: 8.

There are similar problems: no bound control will allow me to address any
values eventhough they display properly on the form. It's as though when I
try to extract the value, there is none/null in the control. Maybe the
records are not being read yet, but they are present and at position 0.

I think I may need to recreate the form. Cleaning code from bad form
sometimes needs that, but I'd like to know why it's failing.
InitializeComponents() fires and so does my InitData() where I fill dataSets,
etc. That's all that's in the form's frmDisplay() method. It's all IDE
created, too. Never had so much trouble. Other forms in the program work
fine. I *must* be missing something obvous.

Thanks again for your reply,

E

James Curran said:
OK, Let's try something different.
Replace the line
this.memoEdit1.Location = new Point(x,500);
with
MessageBox.Show('['+textBox1.Text+']', txtX.ToString());

And tell us exactly what you in the body and in the caption of the
MessageBox

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
Esteban404 said:
I see my communication problem. ;-) textBox1 is the text box (bound to the
datasource from SQL server), txtX is declared int for the purpose of this
test. In any case, converting the value from the bound textBox to int is not
accepted by the new Point() method. I can define a brand new variable, but it
hasn't mattered. I think it'll have to be a switch case process if I can't
get the bound data to work.

Thanks for the reply.

E.
 
I recreated the form and compared the new with the old... the form I was
working with had a logic error in the Form.Load event. I redefined the
Handler and got it to work.. the path comes in and everything displays
correctly. I just wish I knew how to bind an image directly to a form. I'm
old fashioned.

Thanks for your help. Discussion sometimes makes me look at things more
thoroughly.

E.
 
Back
Top