Jump to content
  • Advertisement
Sign in to follow this  
Renegadeandy

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

This topic is 4148 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!