Login | |
|
 |
RE: The trouble with Var's - 10/29/2008 1:26:22 AM
|
|
 |
|
| |
ebgreen
Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
|
This is one of the criticisms of dynamically typed languages. You rely on the interpreter to make typing decisions. If you don't like the typing decisions that it is making, use explicit type casting (CDbl, CInt, etc).
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: The trouble with Var's - 10/29/2008 12:51:33 PM
|
|
 |
|
| |
TNO
Posts: 1402
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
why not convert to a string and check for the existence of the decimal point?
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: The trouble with Var's - 10/30/2008 12:43:59 AM
|
|
 |
|
| |
ebgreen
Posts: 5251
Score: 31
Joined: 7/12/2005
Status: offline
|
I debated that as a way to do the IsWholeNumber function. At the time I couldn't remember how something like this would be represented as a string: nNum = 3 nDiv = 100 nFac = 1000 dblTemp = nNum/nDiv WScript.Echo CStr(dblTemp*1000) I couldn't remember if that would represent the string as 30 or 30.00. I did some testing and it does 30. SO looking for the decimal should work just fine.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: The trouble with Var's - 10/30/2008 3:56:00 AM
|
|
 |
|
| |
TNO
Posts: 1402
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
The OP's question was generic and simple and a generic and simple solution was provided. Nothing was asked about international formatting, nor issues regarding E notation, both of which are generally rare situations. At any rate he did not ask if it was a whole number, he asked if it contained a decimal point or not. If E notation is given, then an E notation number does not contain a decimal which is "correct", the same goes with the international number format. He didn't ask for the separator, he literally asked for the decimal point. Of course I could also ask if 3.00 should pass or fail this test (if precision has to be maintained), but regardless these issues were not brought up so a solution was not given. I didn't assume what he meant I offered a solution to the literal question
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: The trouble with Var's - 10/30/2008 5:10:15 AM
|
|
 |
|
| |
TNO
Posts: 1402
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
With the current information given by the OP, yes that is the proposal I offer since it solves the problem given with the least amount of code. I was not seeking a grand solution for what seems to me to be a domain specific problem
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: The trouble with Var's - 10/30/2008 5:50:50 AM
|
|
 |
|
| |
TNO
Posts: 1402
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
You're giving me a loaded question. As I just said I was not solving the problem of whole number vs not whole number, I was solving the existence of the decimal point or not, which provides the same solution to the OP's problem given. So in the context of that, #1 - The OP's examples define the domain #2 - (based on the premise I just gave): InStr(CStr(Foo),".") = 0
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
|
|