|
-
Apr 24th, 2002, 10:41 AM
#1
Thread Starter
Frenzied Member
VBScript CSng() Type Mismatch
Code:
Dim sngFoo
sngFoo = CSng(someVar)
Am I the only one who thinks that the above code should set sngFoo to 0. or Null and not return a Type Mismatch error if someVar is not numeric?
I guess I have to use this?
Code:
Dim sngFoo
sngFoo = Null
If IsNumeric(someVar) Then sngFoo = CSng(someVar)
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Apr 24th, 2002, 10:46 AM
#2
Fanatic Member
VB Script always returns a type mismatch error if it doesnt like what you are doing. You could try
Code:
sngFoo = CSng(cInt(someVar))
but I doubt that'll even work...
-
Apr 24th, 2002, 10:50 AM
#3
Thread Starter
Frenzied Member
I've never noticed if CInt() would return a Type Mismatch error, too. But nesting the CInt() in the CSng() will loose precision, as n.n would become n and then n..
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|