Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Commas and dots!

Status
Not open for further replies.

episode80

Technical User
Aug 17, 2004
13
FI

I have this program (uses forms) which works just fine, but I also want make sure that the progrma works when the user uses commas, dots or both as decimals in the program while he/she inputs number.

Is it possible to make excel understand this?

At the moment if I input for example 1,3 and 1.3 and the program tries to run it then in return I will get an error or wrong aswer.

This has really bothered me for a long time, I'd be glad if someone could help me with this dilemma!

Thanks!
 
episode80,

It appears that applying this conversion to the particular "A1" cell containing the text like "1,3" would fix the problem. Just run it for every cell in your range.

Range("A1").FormulaR1C1 = Range("A1").Text

Vladk
 

I have two textboxes where the user inputs numbers.

for example if the user inputs 1,3 to the first textbox
and 1.3 to the another textbox the program tries to multiply these two numbers but returns an error because of the different decimal signs.

What would be the proper code to make the program undestand dots and commas as decimal signs (making the program to ingnore the regional settings)?

Thaks for your code Vladk but VB didin't understand it, maybe I formted it wrong. I tried:

Code:
textbox10.formulaR1C1 = textbox10.text


 
episode80,

The code above is for VBA EXCEL since you wanted to make excel understand this.

In VB, try code below substiting Text1 with your own text box names.

Private Sub Text1_KeyPress(KeyAscii As Integer)

If Chr(KeyAscii) = "," Then
KeyAscii = 46
End If

End Sub

Good luck,

Vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top