Re: Strange behaviour of Str$

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



erewhon@xxxxxxxxxx (J French) wrote in
news:4305be23.94347820@xxxxxxxxxxxxxxxxxxxx:

> On Fri, 19 Aug 2005 09:03:17 +0000, "John Carlyle-Clarke"
> <john.cc@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>>At that point, I got an error which looks like it was caused by
>>Str$ returning a number like 2.94 as "2,94".
>
> I would be very surprized if that is really what happened
>
> - Tony explained the Str$() Val() behaviour
>
> Most likely you have a rogue CStr() lurking around
>
> There is some horrible Windows message that notifies Apps of
> settings changes, but I doubt that it would affect Str$()
>
> Put this in a module (one of my favourite tricks for flushing
> things out) :
>
> Public Function CStr( A$, B$) As Object
> End Function
>
> A [Ctl F5] will get the blighter
>
> IMO, and I am in a minority, avoid /anything/ that is locale aware
> - you can build in your own stuff at the presentation layer
> - which makes testing far easier
> - but using locale aware stuff is asking for trouble ...

I agree with what you say, and I like the trick for finding the CStr
occurences. Mostly this app is not locale aware, apart from controls
at the presentation layer which use our own formatting routines.

Personally I think the greatest problem is implicit conversions, e.g.
when using variants. They are very hard to find!

However, I am certain that it is Str$ which is causing the problem.
See my post on how to reproduce.


.



Relevant Pages

  • Re: [ANN] FastRI 0.2.0: full-text searching, smarter search strategies
    ... Returns a copy of _str_ with all lowercase letters replaced with ... their uppercase counterparts. ... The operation is locale ... insensitive---only characters ``a'' to ``z'' are affected. ...
    (comp.lang.ruby)
  • Re: Decimal commas instead of decimal points
    ... Don't mix the locale-aware functions (CStr, CDbl, etc) with the ... with CSng or CDbl) then it automatically expect the correct decimal-point ... These alternatives to CStr and CDbl ... the only two VB functions that don't honour the current locale. ...
    (comp.lang.basic.visual.misc)
  • Re: If the string module is deprecated...
    ... Will they become class-level constants of the str ... real constants, independent of locale, and move locale-dependent stuff ... definitely true that beginners just love coding tests such as 'if c in ...
    (comp.lang.python)
  • Re: Using A2KReportSpecs.mde
    ... I replace all the "Str" call by "Cstr" as you suggest me ... > Well I found the issue Patrick. ... > clsPrintToFit module. ...
    (microsoft.public.access.reports)
  • Re: Help with populating a combo box
    ... So it is better to use the STR and CSTR in my examples but as far as ... did an extra calculation and an extra conversion for no reason I can see. ... If you don't use Str or CStr then VB does an implicit number-to-string ...
    (microsoft.public.vb.general.discussion)