Get the correct decimal character


Q: When the user enters his decimal character in a text box, I want the programme to interpret that as the decimal character for the selected Regional Setting of the machine, irrespectively if  he/she used a comma or a period

A. Try the following

Private Sub Text1_KeyPress(KeyAscii As Integer)
  Dim intDecChar As Integer
  strDecChar = Asc(Mid$(CStr(3/2), 1, 1))
  If (KeyAscii = 44) Or (KeyAscii = 46) Then
    KeyAscii = intDecChar
  End If
End Sub

It may be more efficient to declare intDecChar on module or public level and move the 3rd line above so that it is only performed once for every form or once for every programme execution.

If you have several text boxes, where you want to implement this behaviour, on a form, you should put the procedure above in the Form_KeyPress event and set the Form's Preview property True.