Results 1 to 9 of 9

Thread: [RESOLVED]Convert Comma to Point

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    [RESOLVED]Convert Comma to Point

    Hello;
    When i save my variables to text all point convert to comma. Like below
    Var1=2.2

    if i save it to text
    Print #1, Var1

    it's look like 2,2 in text.

    I rearange regional settings thus my problem fixed but wonder how can i save my data with point without make any changement on regional settings.
    Thanks
    Last edited by levent; Dec 21st, 2007 at 05:52 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Convert Comma to Point

    How about Var1="2.2"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    Re: Convert Comma to Point

    it doesn't work

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Convert Comma to Point

    What happens?

  5. #5
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    272

    Re: Convert Comma to Point

    In my view no problem in this code.



    Code:
    Var1 = 2.2
    filenum1 = FreeFile
    Open "c:\1.txt" For Output As filenum1
    Print #1, Var1
    DONT RUN EXECUTABLE FILES FROM UNKNOWN SOURCES.

  6. #6
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    272

    Re: Convert Comma to Point

    If you find any error in your code or in your setting please let us know in the forums, so that the junior programers can avoid such mistakes like me.
    DONT RUN EXECUTABLE FILES FROM UNKNOWN SOURCES.

  7. #7
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: Convert Comma to Point

    What Hack is saying is this:

    Code:
    Dim var1 as string
    Var1 = "2.2"
    filenum1 = FreeFile
    Open "c:\1.txt" For Output As filenum1
    Print #1, Var1
    Or

    Code:
    Var1 = 2.2
    filenum1 = FreeFile
    Open "c:\1.txt" For Output As filenum1
    Print #1, CStr(Var1)

  8. #8
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Convert Comma to Point

    Options:

    Str$(Var1)

    Replace(CStr(Var1), ",", ".")


    The problem here is locale settings, VB uses locale with certain functions. CStr, Format$ etc. use the system locale settings when handling values.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    Re: Convert Comma to Point

    Hi;


    Print #1, Replace(CStr(Tbn1), ",", ".") worked.

    Thanks everybody who helped

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width