View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen[_4_] Stephen Bullen[_4_] is offline
external usenet poster
 
Posts: 205
Default Textbox input interpretation

Hi Mats,

Hello,
in Sweden it's common to use the comma as a decimal delimiter and the period
as thousand delimiter. I have the Regional and Language Options set
accordingly. Textboxes though treats a number written as 1.234,56 as text as
default formatting is ##,##0.00.
It creates formatting problems reading numbers from cells into textboxes and
vice versa.
Can it be solved?


That will happen if you're trying to write the text from the text box directly
to a cell. Instead, wrap it in the CDbl() function, to explicity convert it to
a number, according to your regional settings:

Range("A1").Value = CDbl(txtBox.Text)

For much more information about this, read the "International Issues" chapter
of the Excel 2002 VBA Programmer's Reference, which is available for download
from my web site (http://www.oaltd.co.uk/ExcelProgRef/Default.htm).

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev