Jump to content
  • Advertisement
Sign in to follow this  
Renegadeandy

[.net] Checking to see if label textbox contents are Integer

This topic is 3974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to a run a bit of code , only if the current contents of two textboxes are integers. In C i would just try casting the contents to an int, if it fails, then its not an int, but I dont know how to do this in VB.net Currently I have this : Private Sub NNumberRequired_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NNumberRequired.TextChanged If NUnitCost.Text Then REM CHECK IF CONTENTS OF TEXTBOX IS AN INT CostOfPurchase.Text = NUnitCost.Text * NNumberRequired.Text End If Please help! Cheers Andy

Share this post


Link to post
Share on other sites
Advertisement
I know how to do it in C#, so I will show you that. It should be trivial to figure out how to convert it.


int val = 0;
if( int.TryParse( textBox.Text, out val ) )
{
// val is the string as an integer
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!