Results 1 to 20 of 20

Thread: Overloaded Operators?

  1. #1

    Thread Starter
    Lively Member Deucy's Avatar
    Join Date
    Mar 2003
    Location
    Cali
    Posts
    85

    Overloaded Operators?

    Hey, everybody.

    I just "upgraded" to VB.NET, boy has it gotten better. My real background is VB6, but I also know C++ which has something that I really appreciate -- overloaded operators. So, can VB.NET overload operators?



    Please say "yes"! Please say "yes"!
    I don't want to search for it myself because I'll deny it if I don't "find" something about overloading operators. I want someone to say "No overloaded operators in VB.NET" for me to believe it.



    **crossing fingers**
    Call me Deuce.[vbcode]
    If User.name = "Deucy" And User.status = "online" Then
    Call Deuce()
    End If
    [/vbcode]

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I don't believe this is available in VB.Net (I haven't seen it yet, but I admit I haven't looked to hard....because of the statement below)

    Good news is that C# does support operator overloading. Since you have some background in C++, you shouldn't have a hard time developing a C# app (assembly) at all, and it uses the same framework that VB.Net does. Even better news... if you just have to overload an operator for a couple classes, you can do that development in C# and compile it to a assembly. Then in your VB.Net project, you can reference that assembly, and call and use it without any hastles. The beauty of .Net....

  3. #3

    Thread Starter
    Lively Member Deucy's Avatar
    Join Date
    Mar 2003
    Location
    Cali
    Posts
    85
    Now that's beautiful!

    Yeah I know C++ and all and I can easily convert to C#, but for some reason, I find it easier for Windows programs (or mini-programs) like mine to use VB. I actually tried to program Windows apps in C++ -- such a hastle, actually. VB takes care of a lot of stuff for me (Paint() or Repaint(), Terminate(), CreateWindow(), etc.). I don't know, but is that also the case for C#? In VB, just click New Form, and you got yourself a form and it's easier to interact among controls. C# too? I hope so, I'd love to convert to C#.
    Call me Deuce.[vbcode]
    If User.name = "Deucy" And User.status = "online" Then
    Call Deuce()
    End If
    [/vbcode]

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    C# is awesome. I learned it first before VB.Net (although I knew VB6 before .net came along). It is just as easy to use as VB.Net in my opinion. There are small differences, but if you are ok with C++, you won't have a problem. It is more strict than VB.Net is, but the functionality is the same. You can drag controls on the form, and do all the stuff you do in VB.Net. As a matter of fact, most code created in C# will compile to the same IL as VB.Net, and you will notice the code is the same, just a different syntax. If you are comfortable with the ';' at the end of statements, and the {} for code blocks, you won't have a problem.

    Here is a link I found. It seems that my earlier statement might not be totally correct as far as the interoperability is concerned:
    http://www16.brinkster.com/saifpia/c...erloading.html

    I will try to find more on this issue, and if there is more, I will post what I find.

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Ok, it looks like if you overload the == operator, vb.net can't handle it because it doesn't use the operator (but it supports the .Equals() method, which you should implement if it will be called from a vb.net app). But, if you overloaded the + or - operator, it would probably work out just like you expect. I guess if the operators used in C# are the same used in VB.Net, it would be ok. Other difference that pops into my mind is the not equals operator:
    <> vb.net
    != C#

  6. #6

    Thread Starter
    Lively Member Deucy's Avatar
    Join Date
    Mar 2003
    Location
    Cali
    Posts
    85
    That is some great info. Thanks a bunch, hellswraith.

    Yeah, I actually prefer the ";" and "{ }" syntax than VB.NET's (I know, such a paradox, me liking VB's functionality but not the syntax).

    As a matter of fact, I'm up for a small project right now, I should give C# a try.



    From the link you gave me above. A question arises:
    In C++ you can overload the "=" (I'm not talking about "=="), but in C# you can't? That's odd! Unless it wasn't enlisted.
    Call me Deuce.[vbcode]
    If User.name = "Deucy" And User.status = "online" Then
    Call Deuce()
    End If
    [/vbcode]

  7. #7

    Thread Starter
    Lively Member Deucy's Avatar
    Join Date
    Mar 2003
    Location
    Cali
    Posts
    85
    That's true.

    Have you actually tried to do that before? It sounds like a working idea, but a lot of doubts come up.

    I'm not so serious about doing it right now, I was just talking in general, cos I found a lot of flexibility and new features in VB.NET, I though OP's (overloaded operators) are there, too.
    Call me Deuce.[vbcode]
    If User.name = "Deucy" And User.status = "online" Then
    Call Deuce()
    End If
    [/vbcode]

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I'm pretty sure operator overloading will be in VB.NET in the next version. Although with your background it sounds like C# is the way to go for you. (I can't believe I just said that)

  9. #9
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Originally posted by Edneeis
    I'm pretty sure operator overloading will be in VB.NET in the next version. Although with your background it sounds like C# is the way to go for you. (I can't believe I just said that)
    Very Funny!
    My next project (year long..) is in VB.NET, so I'm coming back to the dark side!

    Now, I need to pick up a VB.NET book, any recommendations?

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The best reference book I think is Programming in VB.NET by Francesco Balena (http://www.amazon.com/exec/obidos/tg...glance&s=books), but I bet you wont even need a book. After a few days or a week you'll probably adapt to the syntax changes.

  11. #11
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by Lethal
    Very Funny!
    My next project (year long..) is in VB.NET, so I'm coming back to the dark side!

    Now, I need to pick up a VB.NET book, any recommendations?
    You don't need a vb.net book. I had to do a project in VB.Net and it was so simple to get back into. If you know C#, then VB.Net is not a problem (that is if you have vb6 experience, which you do).

    What I worry about is how easy VB.Net is to program with because of the implicit casting and what not. I feel like I am so dirty when I do it...lol. I want to go back to C# as fast as possible.

  12. #12
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by hellswraith
    You don't need a vb.net book. I had to do a project in VB.Net and it was so simple to get back into. If you know C#, then VB.Net is not a problem (that is if you have vb6 experience, which you do).

    What I worry about is how easy VB.Net is to program with because of the implicit casting and what not. I feel like I am so dirty when I do it...lol. I want to go back to C# as fast as possible.
    in vb.net you dont need to cast types?
    \m/\m/

  13. #13

    Thread Starter
    Lively Member Deucy's Avatar
    Join Date
    Mar 2003
    Location
    Cali
    Posts
    85
    Originally posted by PT Exorcist
    in vb.net you dont need to cast types?
    Why would you say that?
    the C# code:

    int i = 10;
    while(i)
    i--;

    will generate a compile error.
    Am I correct on that?
    Call me Deuce.[vbcode]
    If User.name = "Deucy" And User.status = "online" Then
    Call Deuce()
    End If
    [/vbcode]

  14. #14
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yes it doesnt allow it, and i think its good because they're different types
    \m/\m/

  15. #15
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by Edneeis
    I'm pretty sure operator overloading will be in VB.NET in the next version.
    Yup, Whidbey supports operator overloading in VB.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  16. #16
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by crptcblade
    Yup, Whidbey supports operator overloading in VB.

    but it wont support anonimous methods and generic types like C#
    \m/\m/

  17. #17
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    It will have generics but not anonymous methods, although Vb will also have edit & continue and C# wont.

    Actually I don't really miss edit & continue anymore, but I guess it will be nice to have it back.

  18. #18
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Originally posted by hellswraith

    What I worry about is how easy VB.Net is to program with because of the implicit casting and what not. I feel like I am so dirty when I do it...lol. I want to go back to C# as fast as possible.
    I was pretty sure Option Strict disallowed implicit casting in VB.Net.

  19. #19
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    On a side note, Whidbey looks good:

    Operator overloading and COMMENT SUMMARIES! YEH!@!

    I wonder what syntax that will follow?

    VB Code:
    1. '' SUMMARY
    2. This Function reverses order of collection
    3. '' END SUMMARY

    Any guesses?

  20. #20
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I think I read some where that it was something like @ or !@ for the comments.

    I found my source, according to this guy its '@:
    http://www.vsdotnet.be/blogs/tommer/...b-7108e2aad86b
    Last edited by Edneeis; Nov 7th, 2003 at 08:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width