Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 89

Thread: VB - An ActiveX control which restricts a textbox to numbers

  1. #41
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    I've just moved to Europe where they use a comma "," as a decimal point rather than a "."

    If I change the language to English it's fine but there's a problem with Polish for example.

    You probably don't want to have to think about this but how do most windows apps understand that a comma acts as a decimal point.

    The numberbox obviously doesn't allow it's use.

  2. #42

  3. #43
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Martin,

    Can you ignore my last request. When you press . on the numeric keypad it comes up as a comma. I think they are well aware that other countries use a . and that occasionally they need to use the keypad . rather than the numeric pad "."

    I do have one more question though. How do I handle an empty numberbox.

    if nbrbox. is empty then
    if val(nbrbox) is nothing

    if nbrbox.text = "" doesn't work as the contents aren't a string value.

  4. #44

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by sgrya1
    Martin,

    Can you ignore my last request. When you press . on the numeric keypad it comes up as a comma. I think they are well aware that other countries use a . and that occasionally they need to use the keypad . rather than the numeric pad "."

    I do have one more question though. How do I handle an empty numberbox.

    if nbrbox. is empty then
    if val(nbrbox) is nothing

    if nbrbox.text = "" doesn't work as the contents aren't a string value.
    I'm not 100% sure what you mean but the nfollowing works just fine.

    Code:
    Private Sub Command1_Click()
    If NbrTextBox1.Text = "" Then
        MsgBox "error"
    End If
    End Sub

  5. #45
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Oops. Ignore this.
    My mistake.
    Last edited by sgrya1; Jun 22nd, 2007 at 11:46 AM.

  6. #46
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Hey martin, the ff. will break the decimal value, sorry I haven't had time to tinker on the solution...

    Code:
    Private Sub Command1_Click()
        'will display: -.1
        With NbrTextBox1
            .Text = "123456789"
            .SelStart = 0
            .SelText = "-"
            .SelStart = 0
            .SelText = "."
        End With
    End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #47

  8. #48

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Please, try to digit the following number

    -123.4567

    in the NumberBox at run-time in a form with MaxDecimals=2
    and look what happens...

    -7123.45
    Last edited by aleall; Feb 27th, 2008 at 08:01 AM.

  9. #49

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Updated to Version 1.10 which corrected the bug reported by aleall and added a DecimalSeperator property so that the user can decide to show numbers in the American (1234.56) or European (1234,56) style.

  10. #50
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Thanks Martin!

  11. #51

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Thank you

  12. #52

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Another bug to fix?

    if I digit
    123.45.

    that's what happens

    12345.

    if I add two decimal numbers and another point (or comma) like so

    12345.67.

    number become

    1234567.

    ... and so on.

  13. #53

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by aleall
    Another bug to fix?

    if I digit
    123.45.

    that's what happens

    12345.

    if I add two decimal numbers and another point (or comma) like so

    12345.67.

    number become

    1234567.

    ... and so on.
    When a user enters a second decimal point I had to make a choice as to what to do. I chose to remove the first decimal point and that is what you see happening. Maybe it would have been better to just not allow the second one but I'll leave that for another day.

  14. #54
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by MartinLiss
    I'm not sure what you are saying the problem is. What is "ff"?
    The code I posted will only show 1 numeric value after the decimal, I just coded the way I did it manually...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  15. #55

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Updated to Version 1.11 which corrects the bug reported by dee-u in post #46 and changes the way a second decimal seperator is processed as a result of aleall's post #52.

  16. #56
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Martin,

    Can I ask for another very minor thing to be adjusted?

    When you change the border style to 0-None, the text shifts up very slightly and isn't aligned with other traditional textboxes.

    I manually adjusted this somehow in your control but I've forgotten how I did it.

  17. #57

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by sgrya1
    Martin,

    Can I ask for another very minor thing to be adjusted?

    When you change the border style to 0-None, the text shifts up very slightly and isn't aligned with other traditional textboxes.

    I manually adjusted this somehow in your control but I've forgotten how I did it.
    That's normal behavior. In other words it does align with a normal textbox whose border style is 0.

  18. #58
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: VB - An ActiveX control which restricts a textbox to numbers

    How can I make it so I can have more than one decimal put in?

  19. #59

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by bluehairman
    How can I make it so I can have more than one decimal put in?
    Can you show me an example of what you would like the number to look like?

  20. #60
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: VB - An ActiveX control which restricts a textbox to numbers

    An example would be for an IP.
    example:
    111.11.11.11

  21. #61

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Sorry but my control is meant to be used with numbers and that's not a number. You can use a MaskedEdit control for IPs.

  22. #62
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: VB - An ActiveX control which restricts a textbox to numbers

    I noticed a bug. When I have my Max value set to 5000.99 and I type in 8888888 in the box. The number changes to 500099, without the decimal. Which is a much higher number than the max in the first place.. I don't know how to fix this myself and I cannot even compile your source code..

  23. #63

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    It doesn't do that for me. I did notice for the first time however that if I set the MaxValue to 5000.99 that the MinValue also gets set to 5000.99. What is your MinValue? And what do you mean when you say you can't compile my code?

  24. #64
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Ok, I have it set to use a comma not a period. So in the Max value you would have to let the user put ###,## instead of erasing the , when entered in max value. Or change it to whatever decimal the user picks.
    It works when I use a . for the decimal but not ,

    And I get an error somewhere in the source code..

    If you don't get what I say... Whenever a . is entered in the box and I only allow commas, it will delete the period so I end up with 500099
    Last edited by bluehairman; Apr 23rd, 2008 at 06:46 PM. Reason: Mixed up some words

  25. #65

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by bluehairman
    Ok, I have it set to use a comma not a period. So in the Max value you would have to let the user put ###,## instead of erasing the , when entered in max value. Or change it to whatever decimal the user picks.
    It works when I use a . for the decimal but not ,

    And I get an error somewhere in the source code..

    If you don't get what I say... Whenever a . is entered in the box and I only allow commas, it will delete the period so I end up with 500099
    Okay, the comma/period code is new so there may well be a problem. I'll look into it but it won't be until tomorrow.

  26. #66

  27. #67
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Hm.. I received your email but the updated version still seems to have that bug.

    I get an error while trying to compile saying User Defined type not Defined.
    It highlights this line:
    Dim m_DataSource As StdDataFormat

    I tried to fix the bug with this but I cannot test it..
    Private Sub txtNumberBox_KeyUp(KeyCode As Integer, Shift As Integer)
    ......
    On Error Resume Next
    If CDbl(txtNumberBox.Text) > MaxValue Then
    txtNumberBox.Text = MaxValue
    If DecimalSeperator = Comma Then
    txtNumberBox.Text = Replace(MaxValue, ".", ",")
    End If
    End If

    If CDbl(txtNumberBox.Text) < MinValue Then
    txtNumberBox.Text = MinValue
    If DecimalSeperator = Comma Then
    txtNumberBox.Text = Replace(MinValue, ".", ",")
    End If
    End If
    '******* 1.12 End *********
    '******* 1.9 End *********


    End Sub
    Last edited by bluehairman; Apr 28th, 2008 at 10:56 PM.

  28. #68

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    When you say "updated version" are you talking about the one I sent you or v1.12 that I posted here on the 25th? If you mean the former than you should try the v1.12.

  29. #69
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Martin,

    Do you know of a reason why v1.11 and v1.12 would be doing this when I try to compile?

    When I try to make an executable I get an error (see attached) and all the number boxes have a diagonal hatch.

    The program runs inside the IDE fine though.

    Have you seen this before?
    Attached Images Attached Images  

  30. #70

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    The recent changes I made had to do with the difference in the way Europeans format numbers versus the way we in the US do. I'm sure that the problem involves either the System Locale or the Code Locale. Here's what MS has to say about it.

    ______________________________________________________________________

    System Locale vs. Code Locale
    The system locale is the locale of the user who runs your program — it is used as a reference for user input and output and uses Control Panel settings provided by the operating system. The code locale is always English/U.S. in Visual Basic, regardless of which international version you use. Code locale determines the programming language and all the locale-specific settings.
    ______________________________________________________________________

    The change that I made was to change a Val() text-to-number conversion to a Cdbl() because from what I read Val() always assumes that the period is the decimal separator while CDbl use the system locale to determine the decimal separator.

    To test the program I went to the control panel (Regional and Language Options|Regional Options) and changed my system locale from English (United States) to English (United Kingdom) and it worked fine. So assuming that your system locale is English (United Kingdom) I don't understand what's going on but I'll take another look at the program.

  31. #71
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    343

    Re: VB - An ActiveX control which restricts a textbox to numbers

    No, I am in the united states..
    I would just rather the comma than the period but if it is too much trouble (or isn't what you'd like) I can deal with it just being a period.

    Also do you know how to fix my error?

  32. #72

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    I'm really confused about your post #67. What does StdDataFormat have to do with my program. Also at this point I believe my program is working properly. If it's not please tell me what it is doing that is wrong.

  33. #73

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Updated to Version 1.13.

    Please see post #1 for changes and the decription of a known problem. Suggestions for fixing that problem are more than welcome.

  34. #74

  35. #75
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Here's a bug but not sure how easily it could be fixed.

    If a decimal number is in the numberbox, when you highlight the contents to replace it's contents, you can't start off by pressing a decimal point (as there is already a decimal seperator in the cell).

  36. #76

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: VB - An ActiveX control which restricts a textbox to numbers

    Quote Originally Posted by sgrya1 View Post
    Here's a bug but not sure how easily it could be fixed.

    If a decimal number is in the numberbox, when you highlight the contents to replace it's contents, you can't start off by pressing a decimal point (as there is already a decimal seperator in the cell).
    Thanks. After I do my taxes I'll look into it.

  37. #77

  38. #78

  39. #79

  40. #80
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    816

    Re: VB - An ActiveX control which restricts a textbox to numbers

    I have just installed my app on a computer with Vista. I get an error saying Component ‘numberbox.ocx’ or one of its dependencies not correctly registered: a file is missing or invalid.
    Are there any dependancy files that the numberbox.ocx has that may not be on vista computers?

    I found this re Cryst32.ocx. I wonder if it's a similar situation or if I'm just failing something in the installation.

    The most common reason the Cryst32.ocx will not register is that it is missing one or more dependencies.
    To register the crystl32.ocx make sure the following dependencies are present on your machine, then the OCX will register.

    crystl32.ocx Dependencies
    ADVAPI32.DLL
    COMCTL32.DLL
    COMDLG32.DLL
    CRPE32.DLL
    GDI32.DLL
    IMPLODE.DLL
    MFC42.DLL
    MSVCRT.DLL
    MSVCRT20.DLL
    OLE32.DLL
    OLEAUT32.DLL
    OLEDLG.DLL
    OLEPRO32.DLL
    USER32.DLL
    VERSION.DLL

    Please note: while all of these files need to be present in order to successfully register the OCX, some files are system files and should not be distributed.
    Another item to check is that the version number of each dll on the client matches what is on your development machine (or at least matches what is on another client machine where the app does work).

    I recommend using EXTREME CAUTION when moving dlls between a machine with one OS to another with a different one. Regardless of the machines' OS, if you choose to copy dlls, please make sure to back up the old ones in case something goes awry.

    Please note that although the crystl32.ocx file can reside anywhere on your machine (as it is a registered file), its dependencies must reside in the system path.Finally, I would suggest downloading the Dependendency Walker utility from the following link to help troubleshoot your issue:
    http://community.seagatesoftware.com...es/depends.zip

    You can point this utility to Crystl32.ocx on the client machine to determine which of its dependencies the OCX is having issues with.
    Working files show up in green or cyan, while non-working files show up in yellow, orange, or red.
    I am sure that you will find this utility extremely helpful.

    To manually register the OCX after you have ensured that all the dependencies are present, you will need to select :
    Start | Run and type in something like this:
    regsvr32.exe "C:\Windows\System\crystl32.ocx"

    Hope this helps.
    E. McEvoy
    Crystal Reports Consultant

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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



Click Here to Expand Forum to Full Width