+ Reply to Thread
Results 1 to 10 of 10

unusual textbox feature

  1. #1
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    unusual textbox feature

    Hello!

    I have a userform and an textbox on it, which has controlsource in cell A1.

    If I enter decimal number with two decimal places (exapmle:12,34), everything is fine. But if i enter more than two decimal places, the number somehow "loses" comma, and becomes the normal (non-decimal number). For example, if I enter 12,3456 it becomes 123456. Why this happens? How can I solve this problem?

    Thanks In advance
    Attached Files Attached Files
    Last edited by cassiopea; 10-20-2010 at 06:28 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: unusual textbox feature

    When you enter the number

    12,34

    it is interpreted as text

    When you enter the number

    12,345

    it is interpreted as a number with the US formatting convention, using a comma as the thousand separator.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: unusual textbox feature

    Don't use the Controlsource. Use one of the textbox events, such as the Exit event, to write the textbox value to the cell using Cdbl. For example:
    Please Login or Register  to view this content.
    Anyone who confuses correlation and causation ends up dead.

  4. #4
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: unusual textbox feature

    I am new in excel progamming.

    Where exactly should I write this code?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: unusual textbox feature

    Select the textBox in the VB Editor. The right hand drop down lists the control's events
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: unusual textbox feature

    It works if there is some entry in the textbox. But if there isn't, if someone deletes numbers in textbox, error type 13:type mismatch appears!

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: unusual textbox feature

    I would use something like this in your form:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: unusual textbox feature

    Thank you...
    Last edited by cassiopea; 10-20-2010 at 06:27 AM.

  9. #9
    Registered User
    Join Date
    06-29-2015
    Location
    Sumatera
    MS-Off Ver
    2010
    Posts
    1

    Re: unusual textbox feature

    I found this forum while searching similar problem regarding this textbox problem
    I wrote this code for my "data key in" userform

    Please Login or Register  to view this content.
    When I put 0,86254 (no matter how long the numbers after comma), it will be write as number, but if I put x,###..... (x > 0) vba will remove the comma
    I've tried to use this code
    Please Login or Register  to view this content.
    But still didn't work

    Need your advice

  10. #10
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: unusual textbox feature

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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