how to change decimal symbol in VB / Access?

M

MarisB

Hi everyone...

I have a problem i can't resolve for hours...

it's all about decimal symbol in VB...

in windows regional settings "," is selected as decimal symbol, but in VB6
it's interpreted as list seperator, so when i want to assign value
(number:double), it's interpreted as 2 values seprated by comma (","), which
actually should be understood as decimal symbol... when i change decimal
symbol in regional settings to dot ("."), everything is working great, but i
wouldn't like to do so, becouse there's other programs on my pc, required ","
as decimal symbol...

is there any other better way to solve this problem? maybe it's possible to
change the number format in VB (2,54545 to 2.54545 ) or change decimal
symbol in access???

Pleaz help!!!!


here's scrap of code i used...

Dim tBillNo, tVIN as string
Dim t_totSUM as double
tBillNo="CF4354545645"
tVIN="H200MMM"
t_totSUM=100/17
inSQL = "INSERT INTO table 1 (BillNo, VIN, totSUM)" & _
"SELECT '" & tBillNo & "', '" & tVIN & "', " & t_totSUM
Set inRS = CreateObject("ADODB.Recordset")
inRS.Open inSQL, inCON, adOpenStatic
 
T

Tim Ferguson

Dim tBillNo, tVIN as string

Please note: tBillNo is dimmed as a Variant not as a string
Dim t_totSUM as double

string and double has a lower case letters, so I assume that this is not
real code
tBillNo="CF4354545645"


inSQL = "INSERT INTO table 1 (BillNo, VIN, totSUM)" & _
"SELECT '" & tBillNo & "', '" & tVIN & "', " & t_totSUM

there is no space between the parts, therefore inSQL looks like
"...totSum)SELECT..."

t_totSUM is dimmed as a double, so you are asking for it to be coerced
into a string without specifying a format. This is not a reasonable thing
to do: databases and their libraries (i.e. Jet, SQL S, ADO, DAO etc) have
to work independently of regional settings, otherwise it would be
impossible to program them for international use. Therefore, you have to
control all conversions of numbers and dates explicitly. I have not
looked specifically, but I'd bet good money that SQL Server and ADO both
expect american-type numbers with a dot for a decimal separator.

You rally need to do something like

Dim t_totSUM As String

t_totSUM = Format(100/17, "0\.000")

.... the backslash forces the use of a dot rather than whatever OLEAUT32
thinks would look nice.

Hope that helps


Tim F
 
M

MarisB

gaI tried the CODE you sugested but result wasn't such as i expected...
insted of "5.882" i recivded "0.006" :(

MAYBE THERE'S OTHER WAYS TO DO IT, PLS SOMEONE HELP!!!

PS> that's right TIM, some of the code wasn't real, becouse the real code is
much more longer, but i have headache only about this part, so i have to
corect it a bit
 
T

Tim Ferguson

gaI tried the CODE you sugested but result wasn't such as i
expected... insted of "5.882" i recivded "0.006" :(

Okay, fair cop. Sounds like the Format() function has not been sufficiently
tested outside the US...

This is a kludge but works:

? Replace(Format(4/5, "General Number"),",",".")

Note that the General Number is guaranteed not to return any thousands
separators, so there should not be any confusion there.



Best wishes


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top