-
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.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
I'll make a note about that for the future, thanks.
-
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.
-
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
-
Re: VB - An ActiveX control which restricts a textbox to numbers
Oops. Ignore this.
My mistake.
-
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
-
Re: VB - An ActiveX control which restricts a textbox to numbers
I'm not sure what you are saying the problem is. What is "ff"?
-
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 :eek:
-
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.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
-
Re: VB - An ActiveX control which restricts a textbox to numbers
-
Re: VB - An ActiveX control which restricts a textbox to numbers
Another bug to fix? :sick: :afrog:
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.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
Quote:
Originally Posted by aleall
Another bug to fix? :sick: :afrog:
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.
-
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...
-
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.
-
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.
-
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.
-
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?
-
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?
-
Re: VB - An ActiveX control which restricts a textbox to numbers
An example would be for an IP.
example:
111.11.11.11
-
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.
-
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..
-
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?
-
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
-
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.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
Updated to Version 1.12 which corrects the problem with MaxValue and MinValue when the decimal seperator is a comma.
-
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..
Quote:
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
-
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.
-
1 Attachment(s)
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?
-
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.
-
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?
-
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.
-
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.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
-
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).
-
Re: VB - An ActiveX control which restricts a textbox to numbers
Quote:
Originally Posted by
sgrya1
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.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
Updated to Version 1.15. Corrects problem reported in post #75.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
I made a small change to 1.15 so if anyone downloaded it then please download it again.
-
Re: VB - An ActiveX control which restricts a textbox to numbers
-
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.
Quote:
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