+ Reply to Thread
Results 1 to 6 of 6

how to add values in textboxes in user forms

  1. #1
    Registered User
    Join Date
    12-12-2020
    Location
    Cananda
    MS-Off Ver
    office 365
    Posts
    10

    how to add values in textboxes in user forms

    Hi Everyone
    I am stomped by what seems like a simple problem, how to add the value in 2 textboxes and put it into a third one.
    This is my code for a command button, it gets values from the last row of a worksheet, I then want my form to display these, which it does, and then add them in pairs and place the result of addition into a third box for each pair. Instead it concatenates the values

    HTML Code: 

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: how to add values in textboxes in user forms

    Hi there,

    I haven't tested this, but the following approach might be worth a try:

    Please Login or Register  to view this content.

    Hope this helps.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    12-12-2020
    Location
    Cananda
    MS-Off Ver
    office 365
    Posts
    10

    Re: how to add values in textboxes in user forms

    Thank you, That worked perfectly. Could you explain why that is needed?

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: how to add values in textboxes in user forms

    Hi again,

    Thanks for your feedback.


    Could you explain why that is needed?

    Values taken from a TextBox control are always treated as String values (regardless of what they might "look like", e.g. 123.45), and when you try to "add" string values with the "+" operator the effect is to concatenate the two string values.

    Using the CDbl function converts the string values to Double values which may then be added arithmetically.

    Regards,

    Greg M

  5. #5
    Registered User
    Join Date
    12-12-2020
    Location
    Cananda
    MS-Off Ver
    office 365
    Posts
    10

    Re: how to add values in textboxes in user forms

    Thank you again, that is so clear now, You are a true Expert!

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: how to add values in textboxes in user forms

    Stop it, stop it . . . you're making me blush!

    As before, you're very welcome - I'm glad that I was able to help.

    Regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. User Form Textboxes not summing values
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-13-2020, 02:50 PM
  2. How to write a Macro to assign values to protected user forms in another excel
    By meetavdhut in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2018, 09:55 AM
  3. [SOLVED] Ensure TextBoxes are Filled in VBA Forms
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-07-2012, 04:18 PM
  4. Ensure TextBoxes are Filled in VBA Forms
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2011, 09:30 PM
  5. transfer variable values between user forms?
    By max3732 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-13-2010, 06:46 PM
  6. forms: looping through multiple textboxes
    By nerp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2007, 07:50 PM
  7. Auto Add Textboxes in Forms
    By Jasper in forum Excel General
    Replies: 3
    Last Post: 03-01-2005, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1