469,640 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,640 developers. It's quick & easy.

float.Parse works with a breakpoint, doesn't without.

the first and third methods are in a usercontrol object.
txtValue is a TextBox
the float.parse in the if statement on line 3 always works fine.
the second float.parse in the third method is quirky: if the program just
runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text as
null at this point.
However, if I put a breakpoint on the first float.parse (on line 3), and
then step out until i reach the second float.parse, it reports the correct
text value, and the program works as expected.

private void txtValue_TextChanged(object sender, EventArgs e)
{
if (float.Parse(this.txtValue.Text) > 0)
// Call calculation checking class
Form1.SolveCheck();
}

public static void SolveCheck()
{
A = angleA.Value();
B = angleB.Value();
C = angleC.Value();
}

public virtual Corner Value()
{
if (this.Angle)
{
Corner temp = new Corner(float.Parse(this.txtValue.Text),
cmbType.SelectedIndex);
return temp;
}
else { return Corner temp = new Corner(-1.00, -1); }
}

does anyone have any idea what's going on / what im doing wrong?

thank you
Nov 17 '05 #1
3 3118
c0uch <c0***@discussions.microsoft.com> wrote:
the first and third methods are in a usercontrol object.
txtValue is a TextBox
the float.parse in the if statement on line 3 always works fine.
the second float.parse in the third method is quirky: if the program just
runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text as
null at this point.
However, if I put a breakpoint on the first float.parse (on line 3), and
then step out until i reach the second float.parse, it reports the correct
text value, and the program works as expected.


<snip>

Just to check - are you using other threads, or is this all in the UI
thread?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
"c0uch" <c0***@discussions.microsoft.com> schrieb im Newsbeitrag
news:EC**********************************@microsof t.com...
the first and third methods are in a usercontrol object.
txtValue is a TextBox
the float.parse in the if statement on line 3 always works fine.
the second float.parse in the third method is quirky: if the program just
runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text
as
null at this point.
However, if I put a breakpoint on the first float.parse (on line 3), and
then step out until i reach the second float.parse, it reports the correct
text value, and the program works as expected.


<snip>
What are you seeing in the watch window?
Difference of behaviour with and without Breakpoint can depend from
sideeffects of
methods or get-accesors, wich are shown in the watch-window (or locals or
autos-window).
Nov 17 '05 #3
Thanks both of you.

I was making a stupid mistake of not checking to make sure the textbox
wasn't empty before parsing it. I'm used to "step into" going step by step
like with working with assembly. The problem was simply that I didn't realize
when I was doing Step Into the program skipped through the rest of
angleA.Value(), and broke on angleB.Value() (whereas when using the extra bp
it would stop on angleA as i was expecting)...

My apologies, I guess I need to learn more about VS and debugging these high
level languages.
"Christof Nordiek" wrote:
"c0uch" <c0***@discussions.microsoft.com> schrieb im Newsbeitrag
news:EC**********************************@microsof t.com...
the first and third methods are in a usercontrol object.
txtValue is a TextBox
the float.parse in the if statement on line 3 always works fine.
the second float.parse in the third method is quirky: if the program just
runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text
as
null at this point.
However, if I put a breakpoint on the first float.parse (on line 3), and
then step out until i reach the second float.parse, it reports the correct
text value, and the program works as expected.


<snip>
What are you seeing in the watch window?
Difference of behaviour with and without Breakpoint can depend from
sideeffects of
methods or get-accesors, wich are shown in the watch-window (or locals or
autos-window).

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Dave win | last post: by
5 posts views Thread by vivekaseeja | last post: by
34 posts views Thread by yaniv.dg | last post: by
43 posts views Thread by Xancatal | last post: by
45 posts views Thread by Carramba | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.