Results 1 to 6 of 6

Values in textbox are read as strings so I can't add them, how do i solve this?

Threaded View

kjy1989 Values in textbox are read as... 03-06-2014, 04:08 AM
:) Sixthsense :) Re: Values in textbox are... 03-06-2014, 04:11 AM
hemesh Re: Values in textbox are... 03-06-2014, 04:12 AM
Izandol Re: Values in textbox are... 03-06-2014, 04:37 AM
kjy1989 Re: Values in textbox are... 03-06-2014, 10:44 PM
Izandol Re: Values in textbox are... 03-07-2014, 04:50 AM
  1. #1
    Forum Contributor
    Join Date
    12-03-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    107

    Values in textbox are read as strings so I can't add them, how do i solve this?

    I have no idea why excel vba is doing this.

    TextBox_Sum.Value = TextBox_Body + TextBox_Components

    So the textbox sum is supposed to add the amount in textbox_body and the amount in textbox_components. But that doesn't happen, instead, excel puts them together and treats it as a string. For example textbox_body has a value of 2.5 and textbox_components is 2.7, instead of getting 5.2 it returns 2.52.7 !!

    I also tried
    TextBox_Sum.Value = TextBox_Body.value + TextBox_Components.value
    and

    TextBox_Sum.Value = val(TextBox_Body.value) + val(TextBox_Components.value)
    but none of those worked.

    it may be important to note that the values textbox_body and textbox_components are extracted from an excel sheet like so:

    TextBox_body = cells(1,1)


    What am i doing wrong here?
    Last edited by kjy1989; 03-06-2014 at 04:10 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Read & Write textbox
    By crossy5575 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-29-2012, 11:32 AM
  2. Read a Range of 5 cells of strings and assign value of 1-5
    By BeefNoodleSoup in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2012, 12:15 PM
  3. macro to Read Data Strings
    By mithil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2010, 06:25 PM
  4. How to read values from a textbox on a userform
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2010, 04:14 AM
  5. TextBox - Read / Write
    By Herve_Rob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-31-2007, 02:50 PM

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