Ok, I'm about ready to leap out this office window and just end it all here
and now.......

The issue? I get a type mismatch error when trying to multiply a vbLong *
vbDecimal ( I got the data types by checking the value of the VarType ( 3
and 14 respectively). Now can anyone explain to me why these two (clearly
numerical expressions) can't be multiplied? Using my debugger, I can see
that the actual values are 1 and 120000 respectively.

And another thing, two lines prior to this, I converted both expressions to
Currency by using CCur(expression). However, when I look at the data types
as listed in the debuggers "Locals" window, under "Type", they both show up
as "User-defined Type".

Gee...I wonder if Truck Masters is hiring?

Dave

Re: Type Mismatch ??? by Ray

Ray
Thu Jul 31 20:55:15 CDT 2003

How about showing your relevant code before you leap? Come on. One last
shot at life!

Ray at home

--
Will trade ASP help for SQL Server help


"dm_dal" <dmy75252@yahoo.com> wrote in message
news:OYlcxE8VDHA.3404@tk2msftngp13.phx.gbl...
> Ok, I'm about ready to leap out this office window and just end it all
here
> and now.......
>
> The issue? I get a type mismatch error when trying to multiply a vbLong *
> vbDecimal ( I got the data types by checking the value of the VarType ( 3
> and 14 respectively). Now can anyone explain to me why these two (clearly
> numerical expressions) can't be multiplied? Using my debugger, I can see
> that the actual values are 1 and 120000 respectively.
>
> And another thing, two lines prior to this, I converted both expressions
to
> Currency by using CCur(expression). However, when I look at the data
types
> as listed in the debuggers "Locals" window, under "Type", they both show
up
> as "User-defined Type".
>
> Gee...I wonder if Truck Masters is hiring?
>
> Dave
>
>



Re: Type Mismatch ??? by dm_dal

dm_dal
Fri Aug 01 08:06:53 CDT 2003

Ok... so I didn't leap. Don't think I'm weak ( I was just to beat down to
open the window). However, I've got a bottle of bleach ready to drink if I
cant get this to work. Here the code:

vBenefitPlan = "BM1001"
BASE_SALARY = 120000

function CalculateCoverage()
Dim Cmd, Rs
Set Cmd = Server.CreateObject("ADODB.Command")
Cmd.CommandType = adCmdText
Cmd.CommandText = "SELECT LIFE_ADD_COVRG, FLAT_AMOUNT, FACTOR_XSALARY,
COVERAGE_MAXIMUM_FLAT, COVERAGE_MINIMUM_FLAT,
COVERAGE_MAXIMUM_XFACTOR, COVERAGE_MINIMUM_XFACTOR FROM
VW_LIFE_ADD_CHOICES WHERE RECORD_ID = " & strAcctNo & " AND BENEFIT_PLAN =
'" & vBenefitPlan & "' AND NOT COVRG_CD = 'W' ORDER BY
COVRG_CD"

Set Rs = getADORecordSet(Cmd) ''''' This connects to a sql sever 2k db
and returns a disconnected recordset

If Not Rs.EOF Then
LIFE_ADD_COVRG = Rs("LIFE_ADD_COVRG") ''' SqlServer type = char
FLAT_AMOUNT = Rs("FLAT_AMOUNT") ''' SqlServer type = decimal
FACTOR_XSALARY = Rs("FACTOR_XSALARY") ''' SqlServer type = decimal
MAX_F = Rs("COVERAGE_MAXIMUM_FLAT") ''' SqlServer type = decimal
MIN_F = Rs("COVERAGE_MINIMUM_FLAT") ''' SqlServer type = decimal
MAX_X = Rs("COVERAGE_MAXIMUM_XFACTOR") '''SqlServer type = decimal
MIN_X = Rs("COVERAGE_MINIMUM_XFACTOR") ''' SqlServer type = decimal
End If
Set Rs = nothing
Set Cmd = nothing

If ISNumeric(FLAT_AMOUNT) THEN FLAT_AMOUNT = CCur(FLAT_AMOUNT)
IF ISNUMERIC(FACTOR_XSALARY) THEN FACTOR_XSALARY = CCur(FACTOR_XSALARY)
IF ISNUMERIC(MAX_F) THEN MAX_F = CCur(MAX_F)
IF ISNUMERIC(MAX_X) THEN MAX_X = CCur(MAX_F)
IF ISNUMERIC(MIN_F) THEN MIN_F = CCur(MIN_F)
IF ISNUMERIC(MIN_X) THEN MIN_X = CCur(MIN_X)
IF ISNUMERIC(BASE_SALARY) THEN BASE_SALARY = CCur(BASE_SALARY)

IF LIFE_ADD_COVRG = "1" THEN
'###########################################################################
#################
'# For flat coverages (LIFE_ADD_COVRG = 1) all we need to do is return the
FLAT_AMOUNT #
'###########################################################################
#################
COVERAGE = FLAT_AMOUNT ELSEIF LIFE_ADD_COVRG = "2" THEN
'###########################################################################
#################
'# For X_Factor coverages (LIFE_ADD_COVRG) we need to calculate the coverage
amount, # '# making sure we don't exceed the Minimums and Maximums set in
the calc rules table. #
'###########################################################################
#################
' DEBUGGING
T1 = VarType(MAX_X) ''' This returns type=3 (vbLong)
T2 = VarType(BASE_SALARY) ''' This returns type = 14 (vbDecimal)

DBG_VAL = MAX_X * BASE_SALARY '''' Here's where the error is thrown. I
get a type mismatch error

....clip
End Function

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:e5FpE%238VDHA.1480@tk2msftngp13.phx.gbl...
> How about showing your relevant code before you leap? Come on. One last
> shot at life!
>
> Ray at home
>
> --
> Will trade ASP help for SQL Server help
>
>
> "dm_dal" <dmy75252@yahoo.com> wrote in message
> news:OYlcxE8VDHA.3404@tk2msftngp13.phx.gbl...
> > Ok, I'm about ready to leap out this office window and just end it all
> here
> > and now.......
> >
> > The issue? I get a type mismatch error when trying to multiply a vbLong
*
> > vbDecimal ( I got the data types by checking the value of the VarType
( 3
> > and 14 respectively). Now can anyone explain to me why these two
(clearly
> > numerical expressions) can't be multiplied? Using my debugger, I can
see
> > that the actual values are 1 and 120000 respectively.
> >
> > And another thing, two lines prior to this, I converted both
expressions
> to
> > Currency by using CCur(expression). However, when I look at the data
> types
> > as listed in the debuggers "Locals" window, under "Type", they both show
> up
> > as "User-defined Type".
> >
> > Gee...I wonder if Truck Masters is hiring?
> >
> > Dave
> >
> >
>
>



Re: Type Mismatch ??? by Bob

Bob
Fri Aug 01 08:32:25 CDT 2003

OK, let's whittle this down to the relevant lines of code:
dm_dal wrote:
> Ok... so I didn't leap. Don't think I'm weak ( I was just to beat
> down to open the window). However, I've got a bottle of bleach ready
> to drink if I cant get this to work. Here the code:
>
> BASE_SALARY = 120000
<snip>
> MAX_X =
> Rs("COVERAGE_MAXIMUM_XFACTOR") '''SqlServer type = decimal
<snip>
> IF ISNUMERIC(MAX_F) THEN MAX_F = CCur(MAX_F)
> IF ISNUMERIC(MAX_X) THEN MAX_X = CCur(MAX_F)

What does MAX_X contain if either MAX_F or MAX_X is NOT numeric?? Null? A
string? There's your type mismatch right there. You should put some "else"
logic in these if statements ...

IF ISNUMERIC(MAX_F) THEN
MAX_F = CCur(MAX_F)
ELSE
MAX_F = CCur(0)
END IF

> ' DEBUGGING
> T1 = VarType(MAX_X) ''' This returns type=3 (vbLong)
> T2 = VarType(BASE_SALARY) ''' This returns type = 14 (vbDecimal)

This makes no sense. On my machine, VarType(BASE_SALARY) returns 3, not 14.
Why would 120000 cause the subtype to be vbDecimal? Is this a typo on your
part?

>
> DBG_VAL = MAX_X * BASE_SALARY '''' Here's where the error is
> thrown. I get a type mismatch error
>
> ....clip
> End Function
>
HTH,
Bob Barrows



Re: Type Mismatch ??? by dm_dal

dm_dal
Fri Aug 01 08:48:11 CDT 2003

Bob,

[bob asked]
> What does MAX_X contain if either MAX_F or MAX_X is NOT numeric?? Null? A
> string? There's your type mismatch right there. You should put some "else"
> logic in these if statements ...

[dave replies]
These are required fields (not nullable) in the db. In this instance MAX_F
= 0 and MAX_X = 1

[bob asked]
> This makes no sense. On my machine, VarType(BASE_SALARY) returns 3, not
14.
> Why would 120000 cause the subtype to be vbDecimal? Is this a typo on your
> part?

[dave replies]
My bad...it's a typo.
BASE_SALARY 's VarType returns as 3 (vbLong)
MAX_X 's VarType returns as 14 (vbDecimal)

dave

"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:uCAWZFDWDHA.548@tk2msftngp13.phx.gbl...
> OK, let's whittle this down to the relevant lines of code:
> dm_dal wrote:
> > Ok... so I didn't leap. Don't think I'm weak ( I was just to beat
> > down to open the window). However, I've got a bottle of bleach ready
> > to drink if I cant get this to work. Here the code:
> >
> > BASE_SALARY = 120000
> <snip>
> > MAX_X =
> > Rs("COVERAGE_MAXIMUM_XFACTOR") '''SqlServer type = decimal
> <snip>
> > IF ISNUMERIC(MAX_F) THEN MAX_F = CCur(MAX_F)
> > IF ISNUMERIC(MAX_X) THEN MAX_X = CCur(MAX_F)
>
> What does MAX_X contain if either MAX_F or MAX_X is NOT numeric?? Null? A
> string? There's your type mismatch right there. You should put some "else"
> logic in these if statements ...
>
> IF ISNUMERIC(MAX_F) THEN
> MAX_F = CCur(MAX_F)
> ELSE
> MAX_F = CCur(0)
> END IF
>
> > ' DEBUGGING
> > T1 = VarType(MAX_X) ''' This returns type=3 (vbLong)
> > T2 = VarType(BASE_SALARY) ''' This returns type = 14 (vbDecimal)
>
> This makes no sense. On my machine, VarType(BASE_SALARY) returns 3, not
14.
> Why would 120000 cause the subtype to be vbDecimal? Is this a typo on your
> part?
>
> >
> > DBG_VAL = MAX_X * BASE_SALARY '''' Here's where the error is
> > thrown. I get a type mismatch error
> >
> > ....clip
> > End Function
> >
> HTH,
> Bob Barrows
>
>



Re: Type Mismatch ??? by Bob

Bob
Fri Aug 01 09:27:22 CDT 2003

OK, you are going to have to provide me a way to reproduce this. Please
provide the CREATE TABLE script for your table along with some insert
statements to insert smoe sample data into the table. However, something is
still strange:

Bob Barrows

dm_dal wrote:
> Bob,
>
> [dave replies]
> My bad...it's a typo.
> BASE_SALARY 's VarType returns as 3 (vbLong)
> MAX_X 's VarType returns as 14 (vbDecimal)

This is strange: you've used CCur to convert the variable to currency: the
VarType should return 6 - at least, that's what it returns on my box ...

Bob



Re: Type Mismatch ??? by Walter

Walter
Fri Aug 01 10:17:15 CDT 2003

I don't think that VBScript supports using a Decimal subtype in expressions.
I think that you'll have to convert the variable in question to another
subtype such as double, single currency or long before it will be usable in
expressions.

"dm_dal" <dmy75252@yahoo.com> wrote in message
news:OZphOODWDHA.2340@TK2MSFTNGP10.phx.gbl...
> Bob,
>
> [bob asked]
> > What does MAX_X contain if either MAX_F or MAX_X is NOT numeric?? Null?
A
> > string? There's your type mismatch right there. You should put some
"else"
> > logic in these if statements ...
>
> [dave replies]
> These are required fields (not nullable) in the db. In this instance
MAX_F
> = 0 and MAX_X = 1
>
> [bob asked]
> > This makes no sense. On my machine, VarType(BASE_SALARY) returns 3, not
> 14.
> > Why would 120000 cause the subtype to be vbDecimal? Is this a typo on
your
> > part?
>
> [dave replies]
> My bad...it's a typo.
> BASE_SALARY 's VarType returns as 3 (vbLong)
> MAX_X 's VarType returns as 14 (vbDecimal)
>
> dave
>
> "Bob Barrows" <reb_01501@yahoo.com> wrote in message
> news:uCAWZFDWDHA.548@tk2msftngp13.phx.gbl...
> > OK, let's whittle this down to the relevant lines of code:
> > dm_dal wrote:
> > > Ok... so I didn't leap. Don't think I'm weak ( I was just to beat
> > > down to open the window). However, I've got a bottle of bleach ready
> > > to drink if I cant get this to work. Here the code:
> > >
> > > BASE_SALARY = 120000
> > <snip>
> > > MAX_X =
> > > Rs("COVERAGE_MAXIMUM_XFACTOR") '''SqlServer type = decimal
> > <snip>
> > > IF ISNUMERIC(MAX_F) THEN MAX_F = CCur(MAX_F)
> > > IF ISNUMERIC(MAX_X) THEN MAX_X = CCur(MAX_F)
> >
> > What does MAX_X contain if either MAX_F or MAX_X is NOT numeric?? Null?
A
> > string? There's your type mismatch right there. You should put some
"else"
> > logic in these if statements ...
> >
> > IF ISNUMERIC(MAX_F) THEN
> > MAX_F = CCur(MAX_F)
> > ELSE
> > MAX_F = CCur(0)
> > END IF
> >
> > > ' DEBUGGING
> > > T1 = VarType(MAX_X) ''' This returns type=3 (vbLong)
> > > T2 = VarType(BASE_SALARY) ''' This returns type = 14 (vbDecimal)
> >
> > This makes no sense. On my machine, VarType(BASE_SALARY) returns 3, not
> 14.
> > Why would 120000 cause the subtype to be vbDecimal? Is this a typo on
your
> > part?
> >
> > >
> > > DBG_VAL = MAX_X * BASE_SALARY '''' Here's where the error is
> > > thrown. I get a type mismatch error
> > >
> > > ....clip
> > > End Function
> > >
> > HTH,
> > Bob Barrows
> >
> >
>
>



Re: Type Mismatch ??? SOLVED: I think. by Bob

Bob
Fri Aug 01 12:14:47 CDT 2003

I'm still curious as to why you think the ISNUMERIC check is needed: the
columns are decimal datatypes which do not allow Nulls - what could possible
be stored in there that is NOT numeric?

As for vbscript not handling the decimal data subtype, this isn't quite the
case. The issue is that IsNumeric cannot handle the the subtype. Isnumeric
expects a string, or a value that can be implicitly converted to a string.
It turns out that the decimal subtype does not seem to be implicitly
convertible to a string: an explicit conversion is required. Note the
difference between these two if statements:

IF ISNUMERIC(MAX_F) THEN
Response.Write "MAX_F was numeric"
MAX_F = CCur(MAX_F)
else
Response.Write "MAX_F was not numeric"
end if

IF ISNUMERIC(cstr(MAX_F)) THEN
Response.Write "MAX_F was numeric"
MAX_F = CCur(MAX_F)
else
Response.Write "MAX_F was not numeric"
end if

Just to reiterate, the Isnumeric check is not necessary. Simply do this:

If Not Rs.EOF Then
LIFE_ADD_COVRG = Rs("LIFE_ADD_COVRG") ''' SqlServer type = char
FLAT_AMOUNT = ccur(Rs("FLAT_AMOUNT")) ''' SqlServer type = decimal
FACTOR_XSALARY = ccur(Rs("FACTOR_XSALARY")) ''' SqlServer type =
decimal
MAX_F = ccur(Rs("COVERAGE_MAXIMUM_FLAT")) ''' SqlServer type =
decimal
MIN_F = ccur(Rs("COVERAGE_MINIMUM_FLAT")) ''' SqlServer type =
decimal
MAX_X = ccur(Rs("COVERAGE_MAXIMUM_XFACTOR")) '''SqlServer type =
decimal
MIN_X = ccur(Rs("COVERAGE_MINIMUM_XFACTOR")) ''' SqlServer type =
decimal
End If

HTH,
Bob Barrows

dm_dal wrote:
> [ walter said ]
>> I don't think that VBScript supports using a Decimal subtype in
>> expressions. I think that you'll have to convert the variable in
>> question to another subtype such as double, single currency or long
>> before it will be usable in expressions.
>
> [ dave replies ]
> I originally started to say that I tried this and still got the same
> error, however, when I tried this, I did it a little differently.
>
> Example:
> MAX_X = rs("MAXIMUM_COVERAGE_XFACTOR")
>
> Then I did a little check and some conversion:
>
> IF IsNumeric(MAX_X) THEN MAX_X = CDbl(MAX_X)
>
> Ok, with that said, and taking your point into consideration, this
> caused me to wonder {{{ was the type casting really working? }}}
>
> Answer: NO
> Since VBScript cannot handle the data type vbDecimal, then the
> IsNumeric was retuning false and therefore was not casting it as a
> double as expected.
>
> So, it's now working and here's the work around.
> First, when I pull the values from the database, I use the Trim()
> function to cast the resltant data as a string.
>
> MAX_X = Trim(rs("MAXIMUM_COVERAGE_XFACTOR")
>
> Then I do the IsNumeric test and type it as a double using CDbl() and
> now it all works.
>
> Which still leaves me with the question though....If VBScript can't
> handle vbDecimal types, then why would VarType() even be allowed to
> return the type as a result? And secondly, if IsNumeric() actually
> evaluates the expression to see if it can be returned as a numeric
> type, then why does it return false if the value of the expression is
> 1 or 0 or some other number? But....that for another day.
>
> Thank you Walter.....
>
> Dave
>
>
> "Walter Zackery" <PleaseRespond@Newsgroup.com> wrote in message
> news:OF0U7$DWDHA.532@TK2MSFTNGP10.phx.gbl...
>> I don't think that VBScript supports using a Decimal subtype in
>> expressions. I think that you'll have to convert the variable in
>> question to another subtype such as double, single currency or long
>> before it will be usable in expressions.
>>
>> "dm_dal" <dmy75252@yahoo.com> wrote in message
>> news:OZphOODWDHA.2340@TK2MSFTNGP10.phx.gbl...
>>> Bob,
>>>
>>> [bob asked]
>>>> What does MAX_X contain if either MAX_F or MAX_X is NOT numeric??
>>>> Null? A string? There's your type mismatch right there. You should
>>>> put some "else" logic in these if statements ...
>>>
>>> [dave replies]
>>> These are required fields (not nullable) in the db. In this
>>> instance MAX_F = 0 and MAX_X = 1
>>>
>>> [bob asked]
>>>> This makes no sense. On my machine, VarType(BASE_SALARY) returns
>>>> 3, not 14. Why would 120000 cause the subtype to be vbDecimal? Is
>>>> this a typo on your part?
>>>
>>> [dave replies]
>>> My bad...it's a typo.
>>> BASE_SALARY 's VarType returns as 3 (vbLong)
>>> MAX_X 's VarType returns as 14 (vbDecimal)
>>>
>>> dave
>>>
>>> "Bob Barrows" <reb_01501@yahoo.com> wrote in message
>>> news:uCAWZFDWDHA.548@tk2msftngp13.phx.gbl...
>>>> OK, let's whittle this down to the relevant lines of code:
>>>> dm_dal wrote:
>>>>> Ok... so I didn't leap. Don't think I'm weak ( I was just to beat
>>>>> down to open the window). However, I've got a bottle of bleach
>>>>> ready to drink if I cant get this to work. Here the code:
>>>>>
>>>>> BASE_SALARY = 120000
>>>> <snip>
>>>>> MAX_X =
>>>>> Rs("COVERAGE_MAXIMUM_XFACTOR") '''SqlServer type =
>>>>> decimal <snip> IF ISNUMERIC(MAX_F) THEN MAX_F = CCur(MAX_F)
>>>>> IF ISNUMERIC(MAX_X) THEN MAX_X = CCur(MAX_F)
>>>>
>>>> What does MAX_X contain if either MAX_F or MAX_X is NOT numeric??
>>>> Null? A string? There's your type mismatch right there. You should
>>>> put some "else" logic in these if statements ...
>>>>
>>>> IF ISNUMERIC(MAX_F) THEN
>>>> MAX_F = CCur(MAX_F)
>>>> ELSE
>>>> MAX_F = CCur(0)
>>>> END IF
>>>>
>>>>> ' DEBUGGING
>>>>> T1 = VarType(MAX_X) ''' This returns type=3 (vbLong)
>>>>> T2 = VarType(BASE_SALARY) ''' This returns type = 14 (vbDecimal)
>>>>
>>>> This makes no sense. On my machine, VarType(BASE_SALARY) returns
>>>> 3, not 14. Why would 120000 cause the subtype to be vbDecimal? Is
>>>> this a typo on your part?
>>>>
>>>>>
>>>>> DBG_VAL = MAX_X * BASE_SALARY '''' Here's where the error is
>>>>> thrown. I get a type mismatch error
>>>>>
>>>>> ....clip
>>>>> End Function
>>>>>
>>>> HTH,
>>>> Bob Barrows




Re: Type Mismatch ??? SOLVED: I think. by dm_dal

dm_dal
Fri Aug 01 12:44:05 CDT 2003

[ bob writes ]
> I'm still curious as to why you think the ISNUMERIC check is needed: the
> columns are decimal datatypes which do not allow Nulls - what could
possible
> be stored in there that is NOT numeric?

[ dave replies ]
Idunno.....call me a creature of habit. I alway check isNumeric before
trying to explicitly convert any expression to a/n Integer, Long, Single,
Double, Currency or Byte. Make it a habit and you never have to worry about
trying to type-cast a null value.

[ bob writes ]
> As for vbscript not handling the decimal data subtype, this isn't quite
the
> case. The issue is that IsNumeric cannot handle the the subtype. Isnumeric
> expects a string, or a value that can be implicitly converted to a string.
> It turns out that the decimal subtype does not seem to be implicitly
> convertible to a string: an explicit conversion is required. Note the
> difference between these two if statements:

[ dave replies ]
Actually, I dont think IsNumeric "expects" a sting. The doc's say it
expects ANY expression (Variant?). And, obviously the vbDecimal CAN
implicitly be converted to the subtype of string, since Trim() didn't throw
an exception and returned a string.

Personally, I think someone a MS messed up and forgot to upgrade all of
VBScripts functions and methods when the introduced the subtype vbDecimal.
They updated the VarType() function, and obviously Trim(), but forgot to
update the IsNumeric() function and that's what the problem is.

Dave


"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:%23%23hJqBFWDHA.1748@TK2MSFTNGP12.phx.gbl...
> I'm still curious as to why you think the ISNUMERIC check is needed: the
> columns are decimal datatypes which do not allow Nulls - what could
possible
> be stored in there that is NOT numeric?
>
> As for vbscript not handling the decimal data subtype, this isn't quite
the
> case. The issue is that IsNumeric cannot handle the the subtype. Isnumeric
> expects a string, or a value that can be implicitly converted to a string.
> It turns out that the decimal subtype does not seem to be implicitly
> convertible to a string: an explicit conversion is required. Note the
> difference between these two if statements:
>
> IF ISNUMERIC(MAX_F) THEN
> Response.Write "MAX_F was numeric"
> MAX_F = CCur(MAX_F)
> else
> Response.Write "MAX_F was not numeric"
> end if
>
> IF ISNUMERIC(cstr(MAX_F)) THEN
> Response.Write "MAX_F was numeric"
> MAX_F = CCur(MAX_F)
> else
> Response.Write "MAX_F was not numeric"
> end if
>
> Just to reiterate, the Isnumeric check is not necessary. Simply do this:
>
> If Not Rs.EOF Then
> LIFE_ADD_COVRG = Rs("LIFE_ADD_COVRG") ''' SqlServer type = char
> FLAT_AMOUNT = ccur(Rs("FLAT_AMOUNT")) ''' SqlServer type = decimal
> FACTOR_XSALARY = ccur(Rs("FACTOR_XSALARY")) ''' SqlServer type =
> decimal
> MAX_F = ccur(Rs("COVERAGE_MAXIMUM_FLAT")) ''' SqlServer type =
> decimal
> MIN_F = ccur(Rs("COVERAGE_MINIMUM_FLAT")) ''' SqlServer type =
> decimal
> MAX_X = ccur(Rs("COVERAGE_MAXIMUM_XFACTOR")) '''SqlServer type =
> decimal
> MIN_X = ccur(Rs("COVERAGE_MINIMUM_XFACTOR")) ''' SqlServer type =
> decimal
> End If
>
> HTH,
> Bob Barrows
>
> dm_dal wrote:
> > [ walter said ]
> >> I don't think that VBScript supports using a Decimal subtype in
> >> expressions. I think that you'll have to convert the variable in
> >> question to another subtype such as double, single currency or long
> >> before it will be usable in expressions.
> >
> > [ dave replies ]
> > I originally started to say that I tried this and still got the same
> > error, however, when I tried this, I did it a little differently.
> >
> > Example:
> > MAX_X = rs("MAXIMUM_COVERAGE_XFACTOR")
> >
> > Then I did a little check and some conversion:
> >
> > IF IsNumeric(MAX_X) THEN MAX_X = CDbl(MAX_X)
> >
> > Ok, with that said, and taking your point into consideration, this
> > caused me to wonder {{{ was the type casting really working? }}}
> >
> > Answer: NO
> > Since VBScript cannot handle the data type vbDecimal, then the
> > IsNumeric was retuning false and therefore was not casting it as a
> > double as expected.
> >
> > So, it's now working and here's the work around.
> > First, when I pull the values from the database, I use the Trim()
> > function to cast the resltant data as a string.
> >
> > MAX_X = Trim(rs("MAXIMUM_COVERAGE_XFACTOR")
> >
> > Then I do the IsNumeric test and type it as a double using CDbl() and
> > now it all works.
> >
> > Which still leaves me with the question though....If VBScript can't
> > handle vbDecimal types, then why would VarType() even be allowed to
> > return the type as a result? And secondly, if IsNumeric() actually
> > evaluates the expression to see if it can be returned as a numeric
> > type, then why does it return false if the value of the expression is
> > 1 or 0 or some other number? But....that for another day.
> >
> > Thank you Walter.....
> >
> > Dave
> >
> >
> > "Walter Zackery" <PleaseRespond@Newsgroup.com> wrote in message
> > news:OF0U7$DWDHA.532@TK2MSFTNGP10.phx.gbl...
> >> I don't think that VBScript supports using a Decimal subtype in
> >> expressions. I think that you'll have to convert the variable in
> >> question to another subtype such as double, single currency or long
> >> before it will be usable in expressions.
> >>
> >> "dm_dal" <dmy75252@yahoo.com> wrote in message
> >> news:OZphOODWDHA.2340@TK2MSFTNGP10.phx.gbl...
> >>> Bob,
> >>>
> >>> [bob asked]
> >>>> What does MAX_X contain if either MAX_F or MAX_X is NOT numeric??
> >>>> Null? A string? There's your type mismatch right there. You should
> >>>> put some "else" logic in these if statements ...
> >>>
> >>> [dave replies]
> >>> These are required fields (not nullable) in the db. In this
> >>> instance MAX_F = 0 and MAX_X = 1
> >>>
> >>> [bob asked]
> >>>> This makes no sense. On my machine, VarType(BASE_SALARY) returns
> >>>> 3, not 14. Why would 120000 cause the subtype to be vbDecimal? Is
> >>>> this a typo on your part?
> >>>
> >>> [dave replies]
> >>> My bad...it's a typo.
> >>> BASE_SALARY 's VarType returns as 3 (vbLong)
> >>> MAX_X 's VarType returns as 14 (vbDecimal)
> >>>
> >>> dave
> >>>
> >>> "Bob Barrows" <reb_01501@yahoo.com> wrote in message
> >>> news:uCAWZFDWDHA.548@tk2msftngp13.phx.gbl...
> >>>> OK, let's whittle this down to the relevant lines of code:
> >>>> dm_dal wrote:
> >>>>> Ok... so I didn't leap. Don't think I'm weak ( I was just to beat
> >>>>> down to open the window). However, I've got a bottle of bleach
> >>>>> ready to drink if I cant get this to work. Here the code:
> >>>>>
> >>>>> BASE_SALARY = 120000
> >>>> <snip>
> >>>>> MAX_X =
> >>>>> Rs("COVERAGE_MAXIMUM_XFACTOR") '''SqlServer type =
> >>>>> decimal <snip> IF ISNUMERIC(MAX_F) THEN MAX_F = CCur(MAX_F)
> >>>>> IF ISNUMERIC(MAX_X) THEN MAX_X = CCur(MAX_F)
> >>>>
> >>>> What does MAX_X contain if either MAX_F or MAX_X is NOT numeric??
> >>>> Null? A string? There's your type mismatch right there. You should
> >>>> put some "else" logic in these if statements ...
> >>>>
> >>>> IF ISNUMERIC(MAX_F) THEN
> >>>> MAX_F = CCur(MAX_F)
> >>>> ELSE
> >>>> MAX_F = CCur(0)
> >>>> END IF
> >>>>
> >>>>> ' DEBUGGING
> >>>>> T1 = VarType(MAX_X) ''' This returns type=3 (vbLong)
> >>>>> T2 = VarType(BASE_SALARY) ''' This returns type = 14 (vbDecimal)
> >>>>
> >>>> This makes no sense. On my machine, VarType(BASE_SALARY) returns
> >>>> 3, not 14. Why would 120000 cause the subtype to be vbDecimal? Is
> >>>> this a typo on your part?
> >>>>
> >>>>>
> >>>>> DBG_VAL = MAX_X * BASE_SALARY '''' Here's where the error is
> >>>>> thrown. I get a type mismatch error
> >>>>>
> >>>>> ....clip
> >>>>> End Function
> >>>>>
> >>>> HTH,
> >>>> Bob Barrows
>
>
>



Re: Type Mismatch ??? SOLVED: I think. by Bob

Bob
Fri Aug 01 12:54:37 CDT 2003

dm_dal wrote:
> [ dave replies ]
> Actually, I dont think IsNumeric "expects" a sting. The doc's say it
> expects ANY expression (Variant?). And, obviously the vbDecimal CAN
> implicitly be converted to the subtype of string, since Trim() didn't
> throw an exception and returned a string.
>

Oh! You're right!

Hmmm - I have no explanation for this.



Re: Type Mismatch ??? SOLVED: I think. by Ray

Ray
Sat Aug 02 00:54:30 CDT 2003

So what's the story with this thread? Is it worked out? I'm a bit late on
it...

I am also unable to duplicate the problem.

Also, both T1 and T2 return as VarType 6 for me, since they've both been
CCur'ed.

Is it just me, or is it odd that you'd get a VarType of 14? In the VBScript
docs, vartype 14 is not listed as a possible return value for the vartype
function, and also, cdec doesn't exist in vbs. But at the same time, in the
Constants\VarType Constants in the docs, type 14 is listed there.

Ray at home

--
Will trade ASP help for SQL Server help


"Bob Barrows" <reb_01501@yahoo.com> wrote in message
news:%23I$C6XFWDHA.208@tk2msftngp13.phx.gbl...
> dm_dal wrote:
> > [ dave replies ]
> > Actually, I dont think IsNumeric "expects" a sting. The doc's say it
> > expects ANY expression (Variant?). And, obviously the vbDecimal CAN
> > implicitly be converted to the subtype of string, since Trim() didn't
> > throw an exception and returned a string.
> >
>
> Oh! You're right!
>
> Hmmm - I have no explanation for this.
>
>



Re: Type Mismatch ??? SOLVED: I think. by Ray

Ray
Sat Aug 02 13:15:42 CDT 2003

>
> Why don't I search the KB?? Give me a minute .... ah! Here it is!
> http://support.microsoft.com/default.aspx?scid=kb;en-us;195180

Oh yeah, the KB. ;] Nice find. This was interesting. Thanks Bob.

Ray at home