Re: Type mismatch error

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

From: J French (erewhon_at_nowhere.com)
Date: 10/22/04


Date: Fri, 22 Oct 2004 11:39:34 +0000 (UTC)

On Thu, 21 Oct 2004 12:22:37 -0400, "Jacek" <replytonewsgroup@please>
wrote:

>What is wrong with this line:
> If CLng(txtInternational.Text) <= 101 And CLng(txtInternational.Text
>>= -1) And txtInternational.Text <> "N/A" Then
>
>It causes "Type mismatch error".
>But if replace CLng with Val there is not error:
> If Val(txtInternational.Text) <= 101 And Val(txtInternational.Text)
>>= -1 And txtInternational.Text <> "N/A" Then
>
>Why it is so?

CLng() is Locale aware and is intolerant of 'invalid' characters

Val() always recognizes '.' as the decimal point and ignores invalid
characters

Personally I would always use Val() - but out scoped

Function Val(ByVal S$) As Double
    Call StrReplaceAnyChr(S$, "%#!@", "x")
    Call StrReplaceStr(S$, ",", "")
    Val = VBA.Val(S$)
End Function

In my opinion Locale awareness should be explicitly supplied by the
programmer, so that they can write and test a 1.000,50 aware App on a
machine that is set up for 1,000.50



Relevant Pages

  • Re: Reg multilanguage support by gnuplot
    ... The "locale" setting is need in order to interpret 1-byte character ... It is not needed if you are using UTF-8. ... type the characters directly into your command string. ... set label 1 at screen 0.2, ...
    (comp.graphics.apps.gnuplot)
  • Re: MIDP MIDlet: which characters are supported in the phone font?
    ... by the locale where the phone is meant to be used. ... "Which unicode characters does a phone support? ... >> the font set on the phone. ... > I rather doubt any of them do not also display latin letters. ...
    (comp.lang.java.programmer)
  • Re: MIDP MIDlet: which characters are supported in the phone font?
    ... you're going on about the Locale class and saying that my using ... That's why I didn't say *anything* about the font, ... > set of characters displayable by any or all phones meant for that ... Because Korean phones also display non-Korean, ...
    (comp.lang.java.programmer)
  • Re: RegExp to find hex value 0D fails
    ... that the Asc and AscW values for some characters are different: ... artefact of the ASCW function. ... Locale'US English ... the US English locale is different from the AscW value for Czech. ...
    (microsoft.public.scripting.vbscript)
  • Re: MIDP MIDlet: which characters are supported in the phone font?
    ... > by the locale where the phone is meant to be used. ... determines the font that will be used. ... He'll want to choose a font that can display all the characters used in ... in their display resolutions, memory and entry methods to display all the ...
    (comp.lang.java.programmer)