By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
"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

P: n/a
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.