Re: Evil type coercion

From: Rick Rothstein (rickNOSPAMnews_at_NOSPAMcomcast.net)
Date: 11/02/04


Date: Tue, 2 Nov 2004 12:51:06 -0500


> > No more or less than VB could itself Bob ;-)
> >
> > I want the expression semantics to be precisely the same as those in
> > the VB language. Hence, the expression evaluation is passive and
> > makes no assumptions. I was simply a bit surprised to find such a VB
> > "glitch". The original problem was reported to me as a problem in my
> > code, so I'm relieved from that point of view.
>
> I'm not totally clear on how your code relates to the original code so
if
> this is an issue for you it may need to be addressed in both. One
thing
> that may be a factor (assuming I've understood what you are doing
> correctly):
>
> Private Sub Main()
> Debug.Print "1" > 9 : false
> tryit "1", 9
> End Sub
>
> Private Sub tryit(ByVal v1, ByVal v2)
> Debug.Print v1 > v2 ' true
> End Sub

Um, I must be missing something obvious. In your Sub, both v1 and v2 are
variants. You are passing variant value into to them ByVal. To me, that
would mean the Variant with the String sub-type would force the copy it
is passing into the 1st Variant argument to a String sub-type and the
Variant with the Integer sub-type would force the copy it is passing
into the 2nd Variant argument to an Integer sub-type. That would seem to
mean that the comparison inside of your Sub should produce the same
result as the comparison back in Main... but it isn't. What am I
missing?

Rick - MVP



Relevant Pages

  • Re: Code to delete/unlink Linked tables
    ... Public intLinkODBCTables As Variant, intLinkDB2Tables As Variant ... Public strLinkBackendDB As String, strLinkDSNname As String, strLinkLibName ... ' MsgBox "This database is in MDE format...I will delete/recreate ODBC ... Public Sub fncLinkDB2Table() ...
    (microsoft.public.access.modulesdaovba)
  • Re: Difference between Subs and Functions
    ... Robert Morley wrote: ... I didn't say anything about a Sub returning a value. ... The Variant part is the problem, not the Sub Function part. ... In Access it's sometimes necessary to declare a Sub as a Function so ...
    (microsoft.public.vb.general.discussion)
  • Re: Difference between Subs and Functions
    ... Oh, and in either VB6 or VBA, you can't convert a Function to a Sub unless ... The Variant part is the problem, not the Sub Function part. ... In Access it's sometimes necessary to declare a Sub as a Function so ...
    (microsoft.public.vb.general.discussion)
  • Re: Remove method and releasing memory question
    ... simplify your queue and stack. ... Public Sub Add ... Public Function RemoveAs Variant ...
    (microsoft.public.vb.general.discussion)
  • Re: MORE Win Socket trouble
    ... Public Sub Add(newItem As CSocket, Optional Key As Variant) ... ' The private collection used to hold the real data ...
    (microsoft.public.vb.winapi)