Re: Type mismatch error
From: J French (erewhon_at_nowhere.com)
Date: 10/22/04
- Next message: Tony Proctor: "Re: string concatenation - speed optimizing"
- Previous message: Martin Honnen: "Re: Xpath to return element by attribute value"
- In reply to: Jacek: "Type mismatch error"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Tony Proctor: "Re: string concatenation - speed optimizing"
- Previous message: Martin Honnen: "Re: Xpath to return element by attribute value"
- In reply to: Jacek: "Type mismatch error"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|