2 Replies - 885 Views - Last Post: 20 January 2014 - 07:33 AM Rate Topic: ***-- 2 Votes

#1 TheLlamaOfGB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-January 14

How to add multiple variables in VB 2010

Posted 20 January 2014 - 07:13 AM

I'm trying to add multiple variables for an ISBN Digit Checker, which first off adds 10 digits which have all been multiplied by something.
I've got the numbers multiplied within a variable, but they won't add together properly.

 addedanswer = (CStr(CInt(ISBN1) + CInt(ISBN2) + CInt(ISBN3) + CInt(ISBN4) + CInt(ISBN5) + CInt(ISBN6) + CInt(ISBN7) + CInt(ISBN8) + CInt(ISBN9) + CInt(ISBN10))) 


Addedanswer being the variable which is the total of the added numbers. I've gotten as far as adding CInt, then it still refuses to work. I can add two simple numbers like 1 and 2 which works fine, but for some reason, not these...

The one I've displayed shows the answer as over 1.2 million, when the numbers added are 0 20 36 8 0 18 20 32 3 4 in my test, which adds up to 141...

Any help is much appreciated! :bigsmile:

Is This A Good Question/Topic? 0
  • +

Replies To: How to add multiple variables in VB 2010

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: How to add multiple variables in VB 2010

Posted 20 January 2014 - 07:31 AM

Couple of things.

1. VB2010 is VB.Net, so you're actually in the wrong forum. Don't duplicate your post, a mod will move it for you.
2. Where are ISBN1 to ISBN10 populated and what do they relate to (variables (what datatype), textboxes)...can't tell from your code.
3. Have you tried debugging and looking what the actual values of ISBN1 to ISBN10 are?
Was This Post Helpful? 0
  • +
  • -

#3 TheLlamaOfGB  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-January 14

Re: How to add multiple variables in VB 2010

Posted 20 January 2014 - 07:33 AM

Update: I've found the root of the problem does not lie with the adding, it lies within the substrings before. Sorry!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1