Home All Groups Group Topic Archive Search About
Author
30 Jun 2009 1:36 PM
Phil H
Hi

Is there a easy way to compare "Type" structure. Assignment is straight
forward, but comparation does not pass the compiler.

Thanks

Author
30 Jun 2009 2:07 PM
Larry Serflaten
"Phil H" <phung1***@hotmail.com> wrote
> Is there a easy way to compare "Type" structure. Assignment is straight
> forward, but comparation does not pass the compiler.

How about a little example code that you'd like to work?  I'm not exactly
sure what you mean by comparing "Type" structure....

LFS
Are all your drivers up to date? click for free checkup

Author
30 Jun 2009 2:27 PM
Nobody
"Phil H" <phung1***@hotmail.com> wrote in message
news:emor4eY%23JHA.1492@TK2MSFTNGP03.phx.gbl...
> Hi
>
> Is there a easy way to compare "Type" structure. Assignment is straight
> forward, but comparation does not pass the compiler.

You can't. You have to compare the members. If there is more than one member
to compare, make a function for it. Usually I would make a function that
would return the same values as StrComp() function. Putting everything in a
class makes the code easy to maintain and manage. Example:

Public Type TStudent
    FullName As String
    GPA    As Double
End Type

Friend Function CompGPA(st1 As TStudent, st2 As TStudent) As Long
    If st1.GPA > st2.GPA Then
        ' Greater than
        CompGPA = 1
    ElseIf st1.GPA < st2.GPA Then
        ' Less than
        CompGPA = -1
    Else
        ' Equal
        CompGPA = 0
    End If
End Function
Author
30 Jun 2009 7:02 PM
Phil Hunt
Thanks. That's what I am doing now.
I thought there is some 'memory' compare I can use. You see I don't really
care what is different. If I know the struc is different, I know I have to
update the db. Class is nice, but it's the 'type' that really keep relevant
data togehter.


Show quoteHide quote
"Nobody" <nob***@nobody.com> wrote in message
news:evkb57Y%23JHA.5780@TK2MSFTNGP03.phx.gbl...
> "Phil H" <phung1***@hotmail.com> wrote in message
> news:emor4eY%23JHA.1492@TK2MSFTNGP03.phx.gbl...
>> Hi
>>
>> Is there a easy way to compare "Type" structure. Assignment is straight
>> forward, but comparation does not pass the compiler.
>
> You can't. You have to compare the members. If there is more than one
> member to compare, make a function for it. Usually I would make a function
> that would return the same values as StrComp() function. Putting
> everything in a class makes the code easy to maintain and manage. Example:
>
> Public Type TStudent
>    FullName As String
>    GPA    As Double
> End Type
>
> Friend Function CompGPA(st1 As TStudent, st2 As TStudent) As Long
>    If st1.GPA > st2.GPA Then
>        ' Greater than
>        CompGPA = 1
>    ElseIf st1.GPA < st2.GPA Then
>        ' Less than
>        CompGPA = -1
>    Else
>        ' Equal
>        CompGPA = 0
>    End If
> End Function
>
>
Author
30 Jun 2009 7:11 PM
Karl E. Peterson
Phil Hunt wrote:
> Thanks. That's what I am doing now.
> I thought there is some 'memory' compare I can use. You see I don't really
> care what is different. If I know the struc is different, I know I have to
> update the db. Class is nice, but it's the 'type' that really keep relevant
> data togehter.

The "problem" is that the structure only contains pointers to some datatypes.  For
example, if you compare to "equal" structures, you may find they're "different"
because they're each pointing to different copies of the "same" String.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
30 Jun 2009 8:41 PM
Ralph
"Phil Hunt" <a**@aaa.com> wrote in message
news:eltrSVb%23JHA.2872@TK2MSFTNGP05.phx.gbl...
> Thanks. That's what I am doing now.
> I thought there is some 'memory' compare I can use. You see I don't really
> care what is different. If I know the struc is different, I know I have to
> update the db. Class is nice, but it's the 'type' that really keep
relevant
> data togehter.
>

But a Class is a 'type'.

-ralph
Author
30 Jun 2009 9:25 PM
Phil Hunt
The 'type' I am talking about is more like a struc, or group level in the
old days.


Show quoteHide quote
"Ralph" <nt_consultin***@yahoo.com> wrote in message
news:%23fjbVOc%23JHA.4648@TK2MSFTNGP02.phx.gbl...
>
> "Phil Hunt" <a**@aaa.com> wrote in message
> news:eltrSVb%23JHA.2872@TK2MSFTNGP05.phx.gbl...
>> Thanks. That's what I am doing now.
>> I thought there is some 'memory' compare I can use. You see I don't
>> really
>> care what is different. If I know the struc is different, I know I have
>> to
>> update the db. Class is nice, but it's the 'type' that really keep
> relevant
>> data togehter.
>>
>
> But a Class is a 'type'.
>
> -ralph
>
>
Author
30 Jun 2009 11:08 PM
Ralph
"Phil Hunt" <a**@aaa.com> wrote in message
news:uEle6kc%23JHA.2824@TK2MSFTNGP03.phx.gbl...
> The 'type' I am talking about is more like a struc, or group level in the
> old days.
>

lol

.... and your point is?

[But let us not quibble. I'm only suggesting that if you sit back and view
what it is you are trying to do with this collection/group of "relevant
data" - I believe you will discover you have an object or data type. Objects
are defined by 'classes'. Objects know about their 'relevant data', they can
play and morph and compare and generally do useful stuff. Structs are
simple, dull memory blocks that need to be carried around and minded by
external processes.]
Author
1 Jul 2009 12:15 AM
Phil H
The reason I asked in the first place is: it is so easy to assign to UDT,
but it won't let you compare. Case closed.

Show quoteHide quote
"Ralph" <nt_consultin***@yahoo.com> wrote in message
news:OLyCQgd%23JHA.3544@TK2MSFTNGP04.phx.gbl...
>
> "Phil Hunt" <a**@aaa.com> wrote in message
> news:uEle6kc%23JHA.2824@TK2MSFTNGP03.phx.gbl...
>> The 'type' I am talking about is more like a struc, or group level in the
>> old days.
>>
>
> lol
>
> ... and your point is?
>
> [But let us not quibble. I'm only suggesting that if you sit back and view
> what it is you are trying to do with this collection/group of "relevant
> data" - I believe you will discover you have an object or data type.
> Objects
> are defined by 'classes'. Objects know about their 'relevant data', they
> can
> play and morph and compare and generally do useful stuff. Structs are
> simple, dull memory blocks that need to be carried around and minded by
> external processes.]
>
>
>
>

Bookmark and Share