|
-
Aug 16th, 2012, 10:54 AM
#1
Thread Starter
New Member
Issues With Text Boxes
Hi All,
I having a slight issue with Text Boxes and I have never seen this error before.
This form is a DLL which is used by Excel The user Then Loads This Form up and put in the Numbers they require Say they want 4.2 they put that in but it changes it to 24 it removes the decimal Point and it does the same on the Cell in excel where they put the number. You can put the numbers in with decimal places fine in Excel and then when you load the form it will pick it up with the d.p. Why would this do this?
Any ideas how to fix it would be great!
Thanks in advance!
-
Aug 16th, 2012, 11:38 AM
#2
Re: Issues With Text Boxes
So is this a typo or did you really mean to say that it is removing the decimal and reversing the numbers
Say they want 4.2 they put that in but it changes it to 24
As for why it would do it I would say it is in the code but you would have to show some code to get much help.
Also be aware that there is a seperate area here for Office Development which is where Excel related questions should go.
-
Aug 16th, 2012, 01:13 PM
#3
Thread Starter
New Member
Re: Issues With Text Boxes
it is removing the decimal place! Wait until tomorrow when I can get to the code.
-
Aug 16th, 2012, 06:27 PM
#4
Re: Issues With Text Boxes
i have read on some forums that it depends if your computer uses comma for decimal or a point for decimal... in your case maybe your computer uses comma? (i might be wrong)
if it has nothing to do with that... it must be in your code you are converting a variable somewhere and it is messing up
read this
also
Ricky Lee
Does your system use the . (dot) symbol as the decimal symbol? Some european
country use the comma (,) as decimal symbol, and dot (.) as the digit
grouping symbol. If you're in the latter case, the conversion will ignore
the dot and treat the "14.95" as "1495". You can solve this by using
specific CultureInfo object to specify the locale that you want to use.
Hope it helps.
from this link
-
Aug 17th, 2012, 04:34 AM
#5
Thread Starter
New Member
Re: Issues With Text Boxes
Here is the Code to the Textbox:
Private Sub Text1_Change()
Set NHEXL = GetObject(nhename)
If GdxBoo = False Then
Exit Sub
End If
'This stops the form flickering while updating
LockWindowUpdate frmAreaRemove.hwnd
'This allows the form to update when all numbers are removed from the text box
If txtTimeSaver = 0 Then
If Text1.Text = "" Then
Text1.Text = 0
Call updateFormLabels 'Updates the forms labels
txtTimeSaver = 2
End If
End If
If txtTimeSaver = 2 Then
NHEXL.Sheets("" & sheetname).Range("F" & Position).value = Text1.Text
Text1.Text = ""
txtTimeSaver = 1
End If
If Len(Text1.Text) > 0 Then
If IsNumeric(Text1.Text) Then
NHEXL.Sheets("" & sheetname).Range("F" & Position + 1).value = Text1.Text
Call updateFormLabels 'Updates the forms labels
txtTimeSaver = 0
End If
Else
'This line is needed if there is more than one text box
txtTimeSaver = 0
End If
If GdxBoo = True Then
'focus has to shift to something else first
CmdExit.SetFocus
'then we bring the focus back to the text box, user will not even notice
Text1.SetFocus
End If
'This allows the screen to update again
LockWindowUpdate 0
End Sub
-
Aug 17th, 2012, 04:49 AM
#6
Thread Starter
New Member
Re: Issues With Text Boxes
All system Locale Settings are correct so the is no issue there. But when I go to put a coma in instead is fine. The coma isn't removed. With a Coma it just doesn't calculate.
-
Aug 17th, 2012, 08:56 AM
#7
Re: Issues With Text Boxes
You should not be changing the text in text1 within the changed event of that control. This will cause the event to fire again and is a very very bad idea.
-
Aug 17th, 2012, 09:17 AM
#8
Re: Issues With Text Boxes
Try to replace dot with a comma when saving and when loading replace comma with dot... Sorry i dont know how database work yet but if you read my links youll see they have same issue
-
Aug 17th, 2012, 10:59 AM
#9
Re: Issues With Text Boxes
Code:
'This allows the form to update when all numbers are removed from the text box
If txtTimeSaver = 0 Then
If Text1.Text = "" Then
Text1.Text = 0 ' This code will cause the event to fire again
Call updateFormLabels() 'Updates the forms labels
txtTimeSaver = 2
End If
End If
If txtTimeSaver = 2 Then
NHEXL.Sheets("" & sheetname).Range("F" & Position).value = Text1.Text
Text1.Text = "" ' This code will cause the event to fire again
txtTimeSaver = 1
End If
If Len(Text1.Text) > 0 Then
If IsNumeric(Text1.Text) Then
NHEXL.Sheets("" & sheetname).Range("F" & Position + 1).value = Text1.Text
Call updateFormLabels() 'Updates the forms labels
txtTimeSaver = 0
End If
Else
'This line is needed if there is more than one text box
txtTimeSaver = 0
End If
If GdxBoo = True Then
'focus has to shift to something else first
CmdExit.SetFocus()
'then we bring the focus back to the text box, user will not even notice
Text1.SetFocus()
End If
So in the code above if the textbox is blank and txtTimeSaver=0 the code will change txtTimeSaver to 2 and the text in the textbox to 0 then the event will fire again setting texttime saver to 0 and the text to empty which could cause a never ending loop as it would just keep triggering the text changed event.
As a rule you should never ever change the text of a textbox in the Changed event.
I do not know if this may be causing the problem you are seeing but I would deffinitly expect it to cause problems
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|