"."and "," 
Author Message
 "."and ","

Hi ,

we are devel.  a client/server app that uses VB + SQLServer 7.0. In some
cases our app aren't doing calcolations because  the WIN9X are setted to use
"," in "control panel"/"regional settings properties"/"Numbers"/"Decimal
symbol, instead ".".

THe case is that SQL saves the value with ","

Our client in VB will be used in many countries in the world.

How ro set SQLServer or VB to baypass the WIN settings?



Sat, 13 Oct 2001 03:00:00 GMT  
 "."and ","


Fri, 19 Jun 1992 00:00:00 GMT  
 "."and ","
This problem only happens under manipulation of
SQL strings. Something like

"INSERT INTO MyTable (MyValue) VALUES (" & mvarDouble & ")"

In this case if mvarDouble holds something like 125.38 the result
could be:

"INSERT INTO MyTable (MyValue) VALUES (125,38)"
and this is not acceptable as commas are delimiters of
values.

To workaround I use this small routine that fits the need

Public Static Function ReplaceChar(InputText As String, CharToReplace as
string, CharBeingReplaced as String) As String

    Dim sVarWorkString As String
Dim CharPos as Integer

CharPos = Instr(InputText, CharBeingReplaced)
Do while CharPos > 0
    if CharPos = 1 then
        InputText = CharToReplace & Mid$(InputText, 2)
    elseif CharPos = Len(InputText) then
        InputText = Mid$(InputText,1,CharPos-1) & CharToReplace
    else
        InputText = Mid$(InputText,1,CharPos-1) & CharToReplace &
Mid$(InputText,CharPos+1)
    end if
    CharPos = Instr(InputText, CharBeingReplaced)
Loop

ReplaceChar = InputText

End Function

So you sql string may be written as

"INSERT INTO MyTable (MyValue) VALUES (" &
ReplaceChar(Cstr(mvarDouble),".",",") & ")"
that will ALWAYS return:

"INSERT INTO MyTable (MyValue) VALUES (125.38)"

Hope This Helps and bye.


Quote:
>Hi ,

>we are devel.  a client/server app that uses VB + SQLServer 7.0. In some
>cases our app aren't doing calcolations because  the WIN9X are setted to
use
>"," in "control panel"/"regional settings properties"/"Numbers"/"Decimal
>symbol, instead ".".

>THe case is that SQL saves the value with ","

>Our client in VB will be used in many countries in the world.

>How ro set SQLServer or VB to baypass the WIN settings?



Sun, 14 Oct 2001 03:00:00 GMT  
 "."and ","


Fri, 19 Jun 1992 00:00:00 GMT  
 "."and ","

"SELECT * FROM Table WHERE Value = " & STR(VarDouble)



Sun, 14 Oct 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. DLL or something like "#"#ยค#"!"#

2. CSng(Replace("","","")) = 0.0?

3. Renaming "Inbox","Calender", "Send items"

4. : VB6 Problem: "The memory could not be "read"/"written""

5. VB6 Problem: "The memory could not be "read"/"written""

6. How to Replace("String Irregular # of space", "?", "")

7. Trapping "Expand", "Open", "Explore" in Windows Explorer?

8. Detecting "Alt"+"Ctrl"+"Del" Key press

9. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

10. GetObject("","InternetExplorer.Application") fails in Excel VBA

11. SysCmd 603, "path","path"

12. Disabling "BACK"/"FORWARD" buttons

 

 
Powered by phpBB® Forum Software