Page 15 of 23 FirstFirst ... 512131415161718 ... LastLast
Results 561 to 600 of 914

Thread: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

  1. #561
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,734

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    Also, one of the most annoying things they got rid of from is that pesky thing where VB6 always validates a line and throw up a message box whenever you move the cursor off a line and it has a syntax error. This thing drives me absolutely crazy. Modern versions of Visual Studio don't annoy you like this. They just update post updates to a nice little window that lists all the syntax errors you have in your program. You're free to fix them whenever you want without being nagged. This tiny thing by itself makes such a huge difference. I often jump around to check things while writing code so I may not always write a syntactically correct line of code in a one go and having the VB6 IDE annoy me every time for it is just a no-no in my book. This used to annoy me even before our modern IDEs existed.
    That isn't fixed in VS, it's still there. You've just managed to check, or uncheck, some setting to turn it off. I believe I complained about this in a .NET thread back when I first moved to 2019. It was so FAST correcting things that it would check my syntax as I was typing, and all kinds of errors would result, not just on the current line but on down the page. For example, I could type a double quote...and everything until the next double quote, if there even was one, became a string. If there WAS a double quote, then that ended the first string, but it should have started a string, so whatever came after that, which was a string but is now not a string, will fail to compile and cause a bunch of errors.

    For that reason, I often just write "" and then go back and write the string between the double quotes.
    My usual boring signature: Nothing

  2. #562
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,734

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Fifteen!
    My usual boring signature: Nothing

  3. #563
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,683

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    Guard.Against Demo...
    LOL, the "arguments" get thin and thinner.

    Not only would this stuff be easy to implement in a little Vb6-Class in 5 Minutes (with full intellisense of course).
    Though I personally never wanted to... (can't see the big time-saving effect,
    and my brain somehow prefers to see the concrete expression instead of an indirecting Methodname)

    Furthermore, I've found, that if there is a need for extensive Param-validations at all,
    then the validating expressions often tend to be a little bit more complex than just <, <=, >=, >
    (and would in all likelihood *not* be covered by a predefined method in some "Guard-Class").

    I also usually prefer writing a short expression in "positive logic"
    (not invers or "against", but a condition under which I'm willing to make a copy of the Param) -
    putting the error-throwing into the Else-Branch, ending up with easy to read one-liners like that:

    If X > 0 Then mX = X Else Err.Raise ... "X > 0 condition was not met"

    Olaf

  4. #564

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    Though I personally never wanted to... (can't see the big time-saving effect,
    This one is more about code clarity. It's extremely easy to tell in less than a second of looking at it what it does. And of course it's a lot more compact that the traditional method.

    Quote Originally Posted by Schmidt View Post
    If X > 0 Then mX = X Else Err.Raise ... "X > 0 condition was not met"
    No, let's write it out and see:-
    Code:
    Private Sub SetSomeValue(ByVal value As Long)
        If value < 1 Then Err.Raise vbObjectError + 1000, , "Argument cannot be zero or negative"
        '...
    End Sub
    Compared with:-
    Code:
    Public Sub SetSomeValue(ByVal value As Long)
        Guards.GuardAgainstZeroOrNeg value
        '...
    End Sub
    Which one would you rather be reading? Which one is quicker to "parse" in your brain when you look at it?

    Quote Originally Posted by Schmidt View Post
    (and would in all likelihood *not* be covered by a predefined method in some "Guard-Class").
    He covered this. They expose an interface which when combined with extension methods in .Net means you can author your own validation and "tack it on" as if it were written by the original authors. The is how LINQ is implemented by the way.

    Quote Originally Posted by Schmidt View Post
    LOL, the "arguments" get thin and thinner.
    You're too hyper focused on the individual details. Missing the forest for the trees as it were.

    It's about much more than just that Guard library. It's about how multiple things come together to created this beautiful experience. It's about how the intellisense is so effective, it practically writes the code for you. It's about how you can find, download and start using a third party library in your project from right there in the IDE in seconds! It's about the sheer number of little helper libraries out there that are so easily accessible. It's about having so many options and ways of doing things because the Framework and languages are so robust in .Net.

    It's about the experience my man. Everything just comes together so beautifully to create such a positive experience. It's really hard to top that. You just don't get this with VB6. You just don't get this extreme feeling of extreme ease in VB6.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #565

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Eduardo- View Post
    Easy to fix: menu Tools, Options, Editor tab, first item is "Auto Syntax Check", uncheck it.
    Oh Thanks. I went ahead and disabled this garbage as soon as I saw your comment. Always hated it.

    Don't know why I never thought to check and see if it could be disabled. I think I just got used to it living with it.

    Quote Originally Posted by Eduardo- View Post
    It should have been the default I guess.
    I'll go even further and say that this shouldn't even exist. Why would anyone this trash would be useful.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #566
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,527

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    I'll go even further and say that this shouldn't even exist. Why would anyone this trash would be useful.
    From time to time sometimes I temporarily activate it when I don't know what's the error, because the message tells you what is wrong.

  7. #567

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Eduardo- View Post
    From time to time sometimes I temporarily activate it when I don't know what's the error, because the message tells you what is wrong.
    I just tested this and never realized the IDE actually allows a program to run with syntax errors unless you do a Ctrl + F5 (Full compile) run. If there were a way to make Ctrl + F5 the default way of running an application in the IDE, this would more closely resemble how modern Visual Studio works. The only thing that would be missing is the window that lists all errors in code while you're writing it. You'd have to fix them one at a time as they get reported every time you try to do a full compile instead of knowing where they all are at once like you would in modern Visual Studio editions.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #568
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,527

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    (Full compile) run. If there were a way to make Ctrl + F5 the default way of running an application in the IDE
    Options window, General tab, uncheck "Compile on demand".
    That's actually how I have it.

    About the errors that come one at a time... I correct one at a time anyway.

  9. #569

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Eduardo- View Post
    Options window, General tab, uncheck "Compile on demand".
    Ah yes that works. I prefer it this way. It behaves more consistently with what I'm used to in modern VS.

    Quote Originally Posted by Eduardo- View Post
    About the errors that come one at a time... I correct one at a time anyway.
    Well it's a little annoying to press Run each time. Also, it doesn't seem to have a way of seeing just how many of errors you have. I find this to be very valuable when you're copying code from one project to another and you need to know what references are missing.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  10. #570
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,683

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    Code:
    Private Sub SetSomeValue(ByVal value As Long)
        If value < 1 Then Err.Raise vbObjectError + 1000, , "Argument cannot be zero or negative"
        '...
    End Sub
    Compared with:-
    Code:
    Public Sub SetSomeValue(ByVal value As Long)
        Guards.GuardAgainstZeroOrNeg value
        '...
    End Sub
    Which one would you rather be reading?
    The first one of course, because it shows the tested Argument right at the beginning (along with the test-expression).

    The only thing your variant "saves", is the typing of the Error-Texts (but only for "common tests").

    AppCode:
    Code:
    Private mValue As Long
    
    Private Sub Form_Load()
      SetSomeValue 0
    End Sub
    
    Private Sub SetSomeValue(ByVal Value As Long)
      If Value > 0 Then mValue = Value Else Throw ArgNeedsToBePositive
    End Sub
    The above "Value > 0" is the thing I'm really interested in when re-checking my conditions
    (and which my brain parses faster than a looooong CamelCasedTypedFailureCondition).

    And in case you find yourself typing the same error-text again and again, thinking about "DRY" -
    then a little "Throw-Helper"-routine like used above, is set up in a minute or two.

    Such a routine will offer intellisense of course - due to centralizing your userdefined Err-Constants in an Enum.
    Code:
    Public Enum enmErrDefs
      ArgNeedsToBePositive = vbObjectError + 1000
    End Enum
    
    Public Sub Throw(ByVal ErrDef As enmErrDefs)
      Select Case ErrDef
        Case enmErrDefs.ArgNeedsToBePositive: Err.Raise ErrDef, , "The Argument needs to be positive"
        '... put more cases here
      End Select
    End Sub

    Olaf
    Last edited by Schmidt; Sep 24th, 2021 at 07:01 AM.

  11. #571
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    301

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    VB6 is something like 20 years old. Do you know how much has changed in all that time? Olaf tries to keep VB6 up to the times with his vbRichClient library but he is only 1 man. There is only so much a single man can do. Modern frameworks have massive libraries that are being written and maintained by hundreds if not thousands of individuals.

    Niya .... does that mean, according to your claim, that if we had 1000 Olaf, then VB6 would be in the front row?

    You yourself said that Olaf strives to keep VB6 up to date.

    Edit: I don't want to provoke debate, as I have no knowledge of Olaf or Niya.

  12. #572
    Frenzied Member
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    1,235

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Episcopal View Post
    Edit: I don't want to provoke debate, as I have no knowledge of Olaf or Niya.
    Just talking to Niya provokes debate, in fact even talking is not really required.
    By the power invested in me, all the threads I start are Niya and Olaf free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  13. #573
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,734

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by yereverluvinuncleber View Post
    Just talking to Niya provokes debate, in fact even talking is not really required.
    Yeah, that's true.

    If you had 1000 people working to keep VB6 up to date, then it would be up to date.....well, no, actually it wouldn't be. I forgot that 1000 developers can't produce ANYTHING. They'd be totally gridlocked. However, if you had a reasonably sized team working on VB6, it would probably be up to date. That's what TwinBasic is trying to do, but I'm not sure whether their team is sufficient.
    My usual boring signature: Nothing

  14. #574

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    I'm going to throw the 'sixers a bone and talk about one positive thing that using VB6 gives a programmer, a higher level of knowledge and grit.

    I was looking over some of my larger VB6 projects, you know just reminiscing. I saw a lot of stuff I wrote that I can't even remember how half of it works. I don't even know how to do some of the stuff I did back then anymore. .Net spoils you because everything is just so easy. But with VB6, you have to basically do everything yourself. It's like programming in a low level language. You don't just get to import a library and make a couple calls like you could in .Net. You have to hand-roll a lot stuff which requires a higher level of knowledge about lower-level details. Win32 API calls are the most prominent example. You cannot live without them in VB6 but you rarely ever use them in .Net. You could write an entire enterprise level application in .Net without ever making a single Win32 call directly. This is impossible to do in VB6.

    You must know how Windows works. You will almost never see things like VarPtr, StrPtr or CopyMemory in a .Net program but even the most basic VB6 applications sometimes require them. This would requires you to have knowledge about pointers and virtual memory and a whole slew of knowledge that a typical .Net programming just would not need to know.

    In this respect, I'm eternally grateful for VB6 because it required me to learn a lot of stuff I would never have had to learn had I started in VB.Net. This however, doesn't mean I want to go back to writing programs in VB6 or that I would recommend it to anyone over VB.Net. I'm grateful for the knowledge I acquired during my time with VB6, that's true but like I said, it's really necessary to know these things. VB.Net programmers can get along just fine not knowing what a BSTR is or how a pointer works.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  15. #575

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Episcopal View Post
    Niya .... does that mean, according to your claim, that if we had 1000 Olaf, then VB6 would be in the front row?
    If a couple of these "Olafs" also decided to write a better IDE and a modern compiler too then yes.

    TwinBASIC is proof of this. It's not even close to being finished and I already find it far more enjoyable to write programs in than VB6. Half of reasons are because of the VS Code IDE and half are because of the new language features.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  16. #576
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,734

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    I was looking over some of my larger VB6 projects, you know just reminiscing.
    You are weird.


    Still, I do remember one thing I wrote in VB6 where I can't to this day be certain that it actually worked. At the time, I ended up writing several pages trying to explain how the logic worked to see whether or not I could poke a hole in it, or prove that it was sound. I could do neither, in the end, though it was my first foray into over-documenting designs.
    My usual boring signature: Nothing

  17. #577

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Shaggy Hiker View Post
    You are weird.
    So you mean to tell me that you don't like going back to look at code you wrote 10 years ago just to reminisce from time to time?

    Quote Originally Posted by Shaggy Hiker View Post
    Still, I do remember one thing I wrote in VB6 where I can't to this day be certain that it actually worked. At the time, I ended up writing several pages trying to explain how the logic worked to see whether or not I could poke a hole in it, or prove that it was sound. I could do neither, in the end, though it was my first foray into over-documenting designs.
    Yea, people who actually write code should be the last ones to document it. We are a sad lot indeed when it comes to documentation lol...We tend to want to document things the way we write our code.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  18. #578
    Hyperactive Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    301

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    I'm going to throw the 'sixers a bone and talk about one positive thing that using VB6 gives a programmer, a higher level of knowledge and grit.

    I was looking over some of my larger VB6 projects, you know just reminiscing. I saw a lot of stuff I wrote that I can't even remember how half of it works. I don't even know how to do some of the stuff I did back then anymore. .Net spoils you because everything is just so easy. But with VB6, you have to basically do everything yourself. It's like programming in a low level language. You don't just get to import a library and make a couple calls like you could in .Net. You have to hand-roll a lot stuff which requires a higher level of knowledge about lower-level details. Win32 API calls are the most prominent example. You cannot live without them in VB6 but you rarely ever use them in .Net. You could write an entire enterprise level application in .Net without ever making a single Win32 call directly. This is impossible to do in VB6.

    You must know how Windows works. You will almost never see things like VarPtr, StrPtr or CopyMemory in a .Net program but even the most basic VB6 applications sometimes require them. This would requires you to have knowledge about pointers and virtual memory and a whole slew of knowledge that a typical .Net programming just would not need to know.

    In this respect, I'm eternally grateful for VB6 because it required me to learn a lot of stuff I would never have had to learn had I started in VB.Net. This however, doesn't mean I want to go back to writing programs in VB6 or that I would recommend it to anyone over VB.Net. I'm grateful for the knowledge I acquired during my time with VB6, that's true but like I said, it's really necessary to know these things. VB.Net programmers can get along just fine not knowing what a BSTR is or how a pointer works.
    But this is the consequence of modernity. In the past we used to get up to change the TV channel, today we do it with a remote control. Today there are low-code platforms like OutSystem and Salesforce, among others, that increase productivity.

  19. #579

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Episcopal View Post
    But this is the consequence of modernity. In the past we used to get up to change the TV channel, today we do it with a remote control. Today there are low-code platforms like OutSystem and Salesforce, among others, that increase productivity.
    Yep.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  20. #580
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,895

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    No, let's write it out and see:-
    Code:
    Private Sub SetSomeValue(ByVal value As Long)
        If value < 1 Then Err.Raise vbObjectError + 1000, , "Argument cannot be zero or negative"
        '...
    End Sub
    Compared with:-
    Code:
    Public Sub SetSomeValue(ByVal value As Long)
        Guards.GuardAgainstZeroOrNeg value
        '...
    End Sub
    Which one would you rather be reading? Which one is quicker to "parse" in your brain when you look at it?

    For me, the problem with Guards.GuardAgainstZeroOrNeg is that it is easy to parse only if it is actually doing what it claims to do. What if they change the Guard code to eliminate the "=" condition, but don't update the name? Now Guard.GuardAgainstZeroOrNeg is actually guarding against only negative values, but it's much harder to figure that out (you can't at a glance). By contrast, the value < 1 version is easy to read and you know it will do what it says immediately.

    IMHO the best option would be to be able to define conditions like this at the method definition level. Something like:

    Code:
    Public Sub SetSomeValue(ByVal value As Long > 0)
    This kind of thing would be especially nice for methods that take Enums. For example:

    Code:
    Public Enum MyEnum
       myenum_A = 1
       myenum_B 
    End Enum
    
    Public Sub MySub(AB As MyEnum Strict)
       WriteSomethingToRegistry AB   ' We will always only write 1 or 2 here
    End Sub
    
    Sub Form_Load()
       Me.MySub = 3   ' This should raise an error without requiring me to write code to guard against the invalid value I'm trying to pass here
    End Sub
    I suppose a problem would be with enums combined by logical operations like AND, OR. Thinking out loud - that might be solved by StrictAnd, StrictOr keywords. E.g.:

    Code:
    Public Enum MyEnum
       myenum_A = 1
       myenum_B = 2
    End Enum
    
    Public Sub MySub(AB As MyEnum StrictOr)
       WriteSomethingToRegistry AB   ' We will always only write 0 or 1 here
    End Sub
    
    Sub Form_Load()
       Me.MySub = 3  ' This is OK
       Me.MySub = 4  ' This will raise an error.
    End Sub
    Last edited by jpbro; Sep 30th, 2021 at 05:45 AM.

  21. #581
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,956

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Ugh!

    Windows Update just demanded yet another restart in order to finish installing 19MB of security patches to the giant attack surfaces known as .Net Fumbleworks.

    They seriously need to separate this foreign slackware layer from the operating system once again.

  22. #582

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by dilettante View Post
    Ugh!

    Windows Update just demanded yet another restart in order to finish installing 19MB of security patches to the giant attack surfaces known as .Net Fumbleworks.

    They seriously need to separate this foreign slackware layer from the operating system once again.
    You can use Linux.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  23. #583
    PowerPoster
    Join Date
    Feb 2006
    Posts
    22,956

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    We can hope they just pack it all up and move it to Linux.

  24. #584

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by dilettante View Post
    We can hope they just pack it all up and move it to Linux.
    That would be great. Though I'd feel bad for some people. .Net is over there too, but not VB6. There would be a lot of angry VB6 programmers out there in this alternate reality wondering why they got pissed on again.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  25. #585

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Ok Right now I'm mad as hell.

    I'm currently writing a semi-large VB6 project based on a passion project I'm working on in VB.Net. While project in question is quite enjoyable to write, VB6 is such a huge pain in the ass with it's limitations. This is what I want to do:-
    Code:
    Public Class VariableStore
        Private Structure VARIABLE
            Public VarName As String
            Public VarValue As Double
        End Structure
    
        Private _variables As New List(Of VARIABLE)
    
        Public Sub AddVariable(ByVal varName As String, ByVal value As Double)
            _variables.Add(New VARIABLE With {.VarName = varName, .VarValue = value})
        End Sub
    End Class
    The above VB.Net code is exactly what I want to do in VB6. It took me literally 20 seconds to write that code in .Net. However, I've been wrangling for the last hour trying to figure out the best way to get that in VB6. VB6 keeps fighting with me tooth and nail telling me about all the things I can't do.

    VariableStore would obviously be a class module and VARIABLE would be a UDT. This is where the problem starts. I cannot use a Collection internally because VB6 complains that UDTs cannot be coerced into a VARIANT. I could make VARIABLE a class instead of a UDT but the problem I have with that is that it will unnecessarily pollute the public namespace with something that only matters to this class. Not to mention that there are already a bunch of class modules in the project and VB6 has no way to organize them into folders so you can get a sense of what relates to what. You just get this one big list of class modules so adding an extra class module to this list for something that only matters to one class would just makes things more confusing. Using a class module is out of the question as far as I'm concerned.

    The solution I have settled on is to use an array of VARIABLE for the list of variables. Sounds simple, right? Wrong. I now have to decide on the best strategy for testing whether that array has been initialized or not. I think I'm going to use On Error Resume Next in a function to test the array, an ugly hack I never liked by the way. I now have to spend extra time writing that code. I also have to spend a bunch of time writing code for adding elements and resizing the array.

    All of this extra work for something I didn't even have to think about in VB.Net. I know I said before that I didn't hate VB6 but it has been more than 10 years since I wrote a project of this size in this environment and I am really starting to hate VB6. The only thing keeping me going is the joy of seeing the program I'm actually writing working correctly.

    I'm going to be honest, I really don't understand how you guys could put up with this rubbish. Ever since I started this little project, it's been one battle after another with VB6 telling me about all the things I can't do. I have spent more time thinking about how to beat the VB6 compiler rather than how to write the actual program. Anyone who thinks this rubbish is better than VB.Net is out of their freaking mind.

    /end rant

    EDIT:

    Before anyone asks why I don't just use a Collection with the variable name as the key and the variable's value as the value for the entry, I didn't because it's entirely possible that I will want to want to store more information about a variable than just it's value in the future. Using a UDT, all I need to do is add fields to the UDT to represent this information.
    Last edited by Niya; Oct 2nd, 2021 at 08:40 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  26. #586

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Here's what I have decided to do:-
    Code:
    Private Type VARIABLE
        varName As String
        VarValue As Double
    End Type
    
    Private g_Variables() As VARIABLE
    Private g_Count As Long
    
    Public Sub AddVariable(ByVal varName As String, ByVal value As Double)
    
        Dim v As VARIABLE
        
        v.varName = varName
        v.VarValue = value
        
    End Sub
    
    Private Sub Add(var As VARIABLE)
        If g_Count > UBound(g_Variables) Then
            ReDim Preserve g_Variables(0 To UBound(g_Variables) * 2)
        End If
        
        g_Variables(g_Count) = var
        g_Count = g_Count + 1
    End Sub
    
    Private Sub Class_Initialize()
        
        ReDim g_Variables(0 To 10)
       
    End Sub
    It is yet untested so there might be a bug or two.

    I had to expend extra effort towards lower level concerns like managing the array. Not to mention it's a bunch of extra code. Again, look at the VB.Net code that does the exact same thing. Small and straight to the point, easy to write and easy to understand.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  27. #587

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Ok here is the final completed and tested version that implements all that I need for this class:-
    Code:
    Option Explicit
    
    Private Type VARIABLE
        VarName As String
        VarValue As Double
    End Type
    
    Private g_Variables() As VARIABLE
    Private g_Count As Long
    
    Public Sub AddVariable(ByVal VarName As String, ByVal value As Double)
    
        Dim v As VARIABLE
        
        v.VarName = VarName
        v.VarValue = value
        
        Add v
    End Sub
    
    Public Function GetVariableValue(ByVal VarName As String, Optional ByRef out_value As Double) As Boolean
        Dim var As VARIABLE
        
        If FindVar(VarName, var) Then
            out_value = var.VarValue
            GetVariableValue = True
        Else
            GetVariableValue = False
        End If
       
    End Function
    
    Private Function FindVar(ByVal VarName As String, ByRef outVar As VARIABLE) As Boolean
        Dim i As Long
        
        For i = 0 To g_Count - 1
            If LCase(g_Variables(i).VarName) = LCase(VarName) Then
                outVar = g_Variables(i)
                FindVar = True
                Exit For
            End If
            
        Next
    End Function
    
    Private Sub Add(var As VARIABLE)
        If g_Count > UBound(g_Variables) Then
            ReDim Preserve g_Variables(0 To UBound(g_Variables) * 2)
        End If
        
        g_Variables(g_Count) = var
        g_Count = g_Count + 1
    End Sub
    
    Private Sub Class_Initialize()
        
        ReDim g_Variables(0 To 10)
       
    End Sub
    That literally took 3 hours of my life. That tiny little inconsequential class. I was literally battling the VB6 compiler left and right before I came up with something that both me and the compiler could live with. I had to give careful consideration to the tiny details like indexing the array and bounds checking. I had to stop to make sure I got it right and there weren't any off by 1 errors. For example, I had to constantly be thinking about things like is it g_Count? or g_Count - 1?. Something this simple shouldn't require this much thought or effort.

    In contrast it took me 2 minutes to come up with the equivalent in VB.Net:-
    Code:
    Public Class VariableStore
        Private Class VARIABLE
            Public VarName As String
            Public VarValue As Double
        End Class
    
        Private _variables As New List(Of VARIABLE)
    
        Public Sub AddVariable(ByVal varName As String, ByVal value As Double)
            _variables.Add(New VARIABLE With {.VarName = varName, .VarValue = value})
        End Sub
    
        Public Function GetVariableValue(ByVal varName As String) As Nullable(Of Double)
            Dim var = _variables.FirstOrDefault(
                      Function(v) v.VarName.Equals(varName, StringComparison.CurrentCultureIgnoreCase))
    
            If var Is Nothing Then
                Return Nothing
            Else
                Return var.VarValue
            End If
    
        End Function
    
    End Class
    Exactly how I pictured it in my mind is exactly what I wrote. I didn't have to fight with the compiler because I can do this or I can't do that. I didn't have to expend any mental energy towards nonsense like indexing the array. Straight from my mind, and into actual code in about 2 minutes.

    VB.Net gives you the freedom to express your thoughts as code in just about any way you want. VB6 doesn't. Whatever picture you have in your mind about how you want to design something, you can bet that VB6 will have some kind of problem with it. Then you have to spend a whole lot of time negotiating with VB6 about how to manifest what it is in your mind to reality. VB6 is far too restrictive and limited in comparison to VB.Net. Microsoft did a good thing abandoning this trash. That has never been clearer to me than it has been over the past couple days.
    Last edited by Niya; Oct 2nd, 2021 at 09:31 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  28. #588

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    So after spending about 15 minutes negotiating with the VB6 compiler, I discovered Collections, despite not being able to take UDTs, can take arrays, specifically byte arrays. Then I spent another 5 to 10 minutes reworking the class until I came up with this:-
    Code:
    Option Explicit
    
    Private Declare Sub MemCpy Lib "kernel32" Alias "RtlMoveMemory" (ByVal dest As Long, ByVal src As Long, ByVal cb As Long)
    
    Private Type VARIABLEDATA
        value As Double
    End Type
    
    Private g_variables As New Collection
    
    Public Sub AddVariable(ByVal VarName As String, ByVal value As Double)
    
        Dim vd As VARIABLEDATA
        
        vd.value = value
        
        g_variables.Add VarDataToBlob(vd), LCase(VarName)
    End Sub
    
    Private Function GetVariableData(data() As Byte) As VARIABLEDATA
        MemCpy VarPtr(GetVariableData), VarPtr(data(0)), LenB(GetVariableData)
    End Function
    
    Private Function VarDataToBlob(vd As VARIABLEDATA) As Byte()
        Dim blob() As Byte
        
        ReDim blob(0 To LenB(vd) - 1)
        
        MemCpy VarPtr(blob(0)), VarPtr(vd), LenB(vd)
        
        VarDataToBlob = blob
    End Function
    
    Public Function GetVariableValue(ByVal VarName As String, Optional ByRef out_value As Double) As Boolean
        Dim blob() As Byte
        
        On Error Resume Next
            blob = g_variables.Item(LCase(VarName))
            
            'Means we have a match
            If Err.Number = 0 Then
                out_value = GetVariableData(blob).value
                GetVariableValue = True
            Else
                GetVariableValue = False
            End If
        On Error GoTo 0
       
    End Function
    Still dirty but far better than the mess I came up with before. This was truly exhausting.

    But onwards we go.

    This by the way is what I meant when I said grit in this post. It's a constant battle in VB6 to get things to work they way you want!

    Now I can finally take a break from fighting the compiler and get back to the important stuff, like writing the actual program......at least for a little while

    There is still some way to go and no doubt VB6 will try to tie my hands again....can't wait for that
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  29. #589
    Hyperactive Member
    Join Date
    Jun 2019
    Posts
    363

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Why you don't use Dictionary(Of TKey, TValue) in VB.NET? To add (or replace existing key) you can use _vars.Item(varName) = varValue and TryGetValue will do same what you implemented for retrieval.

    If you will use it in "concurrent" (or multi-threaded) app you can go with ConcurrentDictionary to get around concurrency and locking issues.

  30. #590

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by peterst View Post
    Why you don't use Dictionary(Of TKey, TValue) in VB.NET? To add (or replace existing key) you can use _vars.Item(varName) = varValue and TryGetValue will do same what you implemented for retrieval.

    If you will use it in "concurrent" (or multi-threaded) app you can go with ConcurrentDictionary to get around concurrency and locking issues.
    The VB.Net one was contrived quickly just to illustrate a point. While you are indeed correct and this is how it should be done, the point was made even without using a Dictionary. The point I was making was about how much freedom you have to model your thoughts in just about any way you see fit without having to constantly navigate around the limits of the compiler.

    If I were seriously doing this in VB.Net, I would use a Dictionary with the variable name as the key and an object containing data about the variable as the value(In fact, this is exactly what I did in the last VB6 version I posted). And this is only one such way to model a solution to the problem I'm trying to solve. I can think of several different ways to model this solution off the top of my head in VB.Net. I cannot in VB6 because you are only allowed to do so much.
    Last edited by Niya; Oct 2nd, 2021 at 10:50 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  31. #591
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,683

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    I can think of several different ways to model this solution off the top of my head in VB.Net.
    I cannot in VB6 ...
    Exactly.
    In VB6 you act (kinda deliberately) like an absolute Newbie...
    So I cannot really see, why your "opinions about VB6" should have any relevance.

    First of all, for this case - you could use a Collection- or Dictionary-Object (without any additional ClassWrapper) as well.

    And if you *have* to wrap it up in a Class (for more comfort), then it would look more like this:
    Code:
    Option Explicit 'cVarContainer
     
    Private mCol As New Collection
    
    Public Sub AddVariable(ByVal VarName As String, ByVal Value As Double)
       Dim NewVal As New cVarInfo
           NewVal.VarName = VarName
           NewVal.Value = Value
       mCol.Add NewVal, VarName
    End Sub
    
    Public Function Exists(ByVal VarName As String) As Boolean
       On Error GoTo 1
          mCol.Item VarName
    1  Exists = Err = 0
    End Function
    
    Public Function GetVariableValue(ByVal VarName As String) As Double
       GetVariableValue = mCol(VarName).Value
    End Function
    accompanied by a Class-Def instead of an UDT for your Items:
    Code:
    Option Explicit 'cVarInfo
    
    Public VarName As String
    Public Value As Double
    
    'Public TypeName As String
    'Public Scope As String
    'Public IsArrayVar As Booean
    'Public IsUDTVar As Booean
    'Public IsEnumVar As Booean
    But please go on, it's quite entertaining to see you "stumble around in the forrest, looking for trees"...

    Olaf

  32. #592

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Schmidt View Post
    Exactly.
    In VB6 you act (kinda deliberately) like an absolute Newbie...
    So I cannot really see, why your "opinions about VB6" should have any relevance.

    First of all, for this case - you could use a Collection- or Dictionary-Object (without any additional ClassWrapper) as well.

    And if you *have* to wrap it up in a Class (for more comfort), then it would look more like this:
    Code:
    Option Explicit 'cVarContainer
     
    Private mCol As New Collection
    
    Public Sub AddVariable(ByVal VarName As String, ByVal Value As Double)
       Dim NewVal As New cVarInfo
           NewVal.VarName = VarName
           NewVal.Value = Value
       mCol.Add NewVal, VarName
    End Sub
    
    Public Function Exists(ByVal VarName As String) As Boolean
       On Error GoTo 1
          mCol.Item VarName
    1  Exists = Err = 0
    End Function
    
    Public Function GetVariableValue(ByVal VarName As String) As Double
       GetVariableValue = mCol(VarName).Value
    End Function
    accompanied by a Class-Def instead of an UDT for your Items:
    Code:
    Option Explicit 'cVarInfo
    
    Public VarName As String
    Public Value As Double
    
    'Public TypeName As String
    'Public Scope As String
    'Public IsArrayVar As Booean
    'Public IsUDTVar As Booean
    'Public IsEnumVar As Booean
    But please go on, it's quite entertaining to see you "stumble around in the forrest, looking for trees"...

    Olaf
    I specifically mentioned I wanted to avoid using classes to model the variable data because it would pollute the public name space of the project. The VB6 IDE just gives you one long unorganized list of class modules in a project and I wanted to minimize the number of class modules in the project so it doesn't look bigger than it actually is. I really don't want to have dozens of class modules with only 2 or 3 fields polluting the IDE. If UDTs were friendly to use, I could have put a lot of this into a single module or group related UDTs into their own modules or their own class modules. This would keep the project neat, organized and far easier to understand. What I'm talking about here is the ability to encapsulate data structures. A project where data structures can be grouped either privately or publicly instead just having everything just out in the open is far easier to understand. It would be easy to tell what belongs to what.

    I've since moved on from this problem. I've decided it's not worth the hassle. If the project ends up being polluted with dozens of tiny class modules, then so be it. There is nothing I can do about it.

    I've also decided to roll up my sleeves and solve my problems with Collections and Arrays by using the Collection class as a base to build my own strongly typed Collection-like classes. I may even take the advice you gave me in the other thread and just build my own List<T> base using normal arrays.

    I love you but you have to be crazy if you think all this mess and extra work is better than what we have in .Net. None of the things I've talked about here are even issues in .Net. VB.Net and modern Visual Studio editions are far and I mean far superior to VB6. Like I said before, this has never been clearer to be than it is now.
    Last edited by Niya; Oct 3rd, 2021 at 11:19 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  33. #593

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    And by the way, the project I'm doing, I already did in .Net and it took a fraction of the time because I didn't have to spend all this time worrying about writing my own Collections or trying to find ways to encapsulate data structures.

    I'm having fun doing this project, no lie....but goddamn! VB6 is primitive as hell. You guys have no idea how much you're torturing yourselves lol

    The joy of the project for me is seeing the program working correctly and exactly as I want but I can't say there is any joy in actually writing the code. Jesus, it's painful!

    There's also a small amount of enjoyment in testing myself to see how well I can overcome the limitations of VB6. But beyond pet projects like this and the odd contribution here and there on these forums, I can't take VB6 seriously as a Windows development tool while something like .Net and Visual Studio 2019 exists. This is not to say VB6 is bad in a completely objective sense, it's just that VB.Net+VS2019 are just sooooooooo much better. It's a night and day difference.
    Last edited by Niya; Oct 3rd, 2021 at 11:56 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  34. #594
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    36,734

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    And by the way, the project I'm doing, I already did in .Net and it took a fraction of the time because I didn't have to spend all this time worrying about writing my own Collections or trying to find ways to encapsulate data structures.
    Well, I'd say that Olaf doesn't want to, either, as that seems to be part of the rationale behind RC5/6.

    With .NET, MS built a series of libraries that extended the language to do new things. They didn't do the same for VB6, but it rather looks like Olaf DID do so. You might say that it shows what could have been. After all, in the end, it's all just byte code. Every language is built up from the byte code, and can be seen as being built up in layers...though the boundaries between layers are not always evident or meaningful.
    My usual boring signature: Nothing

  35. #595

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Shaggy Hiker View Post
    Well, I'd say that Olaf doesn't want to, either, as that seems to be part of the rationale behind RC5/6.

    With .NET, MS built a series of libraries that extended the language to do new things. They didn't do the same for VB6, but it rather looks like Olaf DID do so. You might say that it shows what could have been. After all, in the end, it's all just byte code. Every language is built up from the byte code, and can be seen as being built up in layers...though the boundaries between layers are not always evident or meaningful.
    Olaf cannot change the compiler. A lot of the things we enjoy in VB.Net/C# etc are actually implemented by the compiler and not the framework. Generics, delegates and Async/Await are some of the most well known examples.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  36. #596
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,683

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Quote Originally Posted by Niya View Post
    The joy of the project for me is seeing the program working correctly and exactly as I want -
    but I can't say there is any joy in actually writing the code.
    Jesus, it's painful!
    Still not sure, what you're really after...
    Currently it seems (again), that it is "comfort" you're seeking whilst developing
    (complaining about, that VB6 is too "low-level" for your taste).

    Well, if it's that, then why do you deny yourself the comfort of some little helper-lib in your VB6-endeavours.

    E.g. your latest efforts regarding VB6 can be seen here:


    If it's about writing comfort-oriented (with fewer lines, using battle-hardened Helper-Classes),
    your main-output could be accomplished in VB6+RC6 this way:
    Code:
    Sub Main()
      Const sInputVars = "a=16, b=200, c=150"
      Const Expression = "Sqr(Sqr(2 * b + Sqr(a)) * (c / 2))"
      
      With New_c.Formula
        Dim V
        For Each V In Split(sInputVars, ",")
           .SetVar Trim(Split(V, "=")(0)), Val(Split(V, "=")(1))
        Next
        
        Debug.Print .Evaluate(Expression)
      End With
    End Sub
    The above will print out: 38.8262970571253

    And JFYI (since you were complaining about the "amount of Class-Files needed in VB6"):
    - cFormula is implemented in a single VB6 Class (about 350 LOC)
    - the only other Helper-Object in it is: mVariables as RC6.cCollection (taking up "VarNameKey/Value-pairs" directly)
    - no APIs, no UDTs

    And yes, I had fun writing it - but I know the language in and out...

    So, I'd refrain comparing said fun with other languages/frameworks,
    when I'm still operating at Newbie-Level (having only dabbled for a few hours in them).
    Who would take such "judgments" serious, if I did that?

    Olaf

  37. #597

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Whoa there buddy. Slow down.

    Quote Originally Posted by Schmidt View Post
    If it's about writing comfort-oriented (with fewer lines, using battle-hardened Helper-Classes),
    your main-output could be accomplished in VB6+RC6 this way:
    I know. Evaluating expressions is not the main point. It's only part of it.

    Quote Originally Posted by Schmidt View Post
    And yes, I had fun writing it - but I know the language in and out...

    So, I'd refrain comparing said fun with other languages/frameworks,
    when I'm still operating at Newbie-Level (having only dabbled for a few hours in them).
    Who would take such "judgments" serious, if I did that?
    Bro. Get off it. VB6 is garbage compared to VB.Net. Doesn't matter how well you can use it.

    Also, stop taking this so personal. You act like VB6 is your woman who's honor got insulted or something. It's just a tool. No need to get so triggered by my opinions. Would you get so offended if I showed contempt for your favorite screwdriver?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  38. #598

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    You know I'm beginning to understand that there is a fundamental difference between me and some of the VB6 people here like Olaf. Some of you have such a deep love affair with VB6 whereas I see it as just a tool. VB.Net is also a tool and it happens to be a better one. Why does this simple fact offend so many people? I understand that we are very passionate people but come on man.

    You think I get this triggered when I hear people say C# is better language than VB.Net. There is very strong evidence to support this claim and yet unlike some of you, it doesn't make me feel any type of way. It's just how it is. I don't use VB.Net over C# because I've convinced myself through a bunch of mental gymnastics that it is better. I use it simply because I love it more and I'm more accustomed to the language. I will always recommend C# over VB.Net to anyone that asks because I can be objective and still love VB.Net at the same time! You use VB6 because you love and know it, not because it's better. It's as simple as that. Unlike some of you, I recognize that my love for something doesn't automatically mean its better in any objective sense.
    Last edited by Niya; Oct 3rd, 2021 at 07:51 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  39. #599

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Forgot to address this.

    Quote Originally Posted by Schmidt View Post
    Still not sure, what you're really after...
    Currently it seems (again), that it is "comfort" you're seeking whilst developing
    (complaining about, that VB6 is too "low-level" for your taste).
    I'm not sure how I can explain this. It's a feeling. Like VB6 has a lot of pain points for sure but there is a feeling of satisfaction you get from doing something in VB6 and seeing it finally work after fighting tooth and nail trying to figure out how to do it. You feel like, "if I can do this in VB6, I can do it any language" You know? That feeling is like a drug and it's part of the reason that despite how painful using VB6 is, this project overall has been a lot of fun for me to work on. Just seeing it come together, piece by piece is a kind of high. I don't get the same rush in VB.Net because everything is so easy.

    Basically, I'm a junkie for punishment. That's the best way I can put it. It's thrilling to do something like this in a primitive environment like VB6.

    VB.Net is like taking a test and being handed all the answers and using VB6 is like having to thrash around with all of your might until you figure out the answer for yourself. Which one sounds more fun if you're in the mood for a challenge?

    But make no mistake. When it's time for the rubber to me the road and I just need to get things done as quickly and as painlessly as possible, it won't be in VB6. You can bet that.
    Last edited by Niya; Oct 3rd, 2021 at 05:53 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  40. #600

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    6,661

    Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....

    Also I want to say something to all the VB6 people including Olaf.

    I want you all to know that none of this is personal to me. I know that me and a few of you have locked horns for many years over this VB.Net vs VB6 thing. Know this. Do not make the mistake of thinking I hate any of you or hold any kind of contempt towards any of you. I think all of you are wonderful people and I have a lot of respect for the knowledge and skill of all the regulars here, regardless of what language they use. There is only one person that actually rubbed me the wrong way when he made it very personal and you all should know who I'm talking about. And no, it's not Olaf. Aside from that person, I have no problems with any of you.

    My feelings towards VB6 and it's relationship to .Net has nothing whatsoever to do with my opinions about any of you as people. I hold VB.Net being better than VB6 as an objective fact. I have not seen any evidence to contradict this but I'm always willing to debate it and that's as far as it goes. I don't leave these discussions with hate or contempt in my heart for the people here that hold opposing points of view. I don't hate people that love VB6 but that doesn't mean I will completely ignore it's many failings, nor does it mean I won't attempt to discuss why I think VB.Net is better.

    So please, stop interpreting my gripes with VB6 as attacks against you guys. It is not about you. It's just about the language, IDE etc.
    Last edited by Niya; Oct 3rd, 2021 at 09:05 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Page 15 of 23 FirstFirst ... 512131415161718 ... LastLast

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