[.net] Checking to see if label textbox contents are Integer
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
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}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement