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

Conversion from string "" to type 'Integer' is not valid.

P: 1
I know this question has been addressed, however none of the suggested fixes are resolving the issue.

This one causes the error (initial value of txtPoint.Text is 35):
Expand|Select|Wrap|Line Numbers
  2. Private Sub nudPoints_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudPoints.ValueChanged
  3.        Dim points As Integer = CInt(txtPoint.Text) + nudPoints.Value + nudMiscPoints.Value
  4.       txtPointsTotal.Text = points
  5.   End Sub
  8. This one works fine (initial value of txtAppraise.Text is 0):
  10. Private Sub nudMiscAppraise_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudMiscAppraise.ValueChanged
  11.     Dim total As Integer = CInt(txtAppraise.Text) + nudAppraise.Value + nudMiscAppraise.Value
  12.     txtAppraiseTotal.Text = total
  13.   End Sub
Neither have any trailing spaces, special characters, or letters. I have tried scrapping the problematic Sub and rebuilding it using different variables and it still generates the error. My limited training has got me at a loss. Any help would be greatly appreciated.
Dec 10 '09 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 7,872
Use Integer.Parse() instead of the old VB methods
Dec 15 '09 #2

Expert Mod 5K+
P: 9,731
Better yet, try using the Integer.TryParse() method.

Dec 15 '09 #3

P: 1
Expand|Select|Wrap|Line Numbers
  1. Private Sub nudPoints_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudPoints.ValueChanged
  2. Dim points As Integer = Int32.Parse(txtPoint.Text) + nudPoints.Value + nudMiscPoints.Value
  3. txtPointsTotal.Text = points
  4. End Sub
Jun 6 '10 #4

Expert Mod 5K+
P: 9,731
CsharpChico, what is your code supposed to be showing us?

Right now, if you try to run the code you will get a warning (maybe an error if your Visual Studio's settings are high enough) because you are trying to assign an integer to a Text property (which expects a string).

Jun 7 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.