Page 3 of 24 FirstFirst 12345613 ... LastLast
Results 81 to 120 of 939

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

  1. #81

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Well I don't know what to say other than to tell you when I write VB6 code in the VB6 IDE I feel like I'm writing it in NotePad. All little things and the big things mentioned in this thread add up to a vastly superior user experience when writing applications.

    Quote Originally Posted by baka View Post
    everything is coding. what can .NET do that I can not do in VB6?
    You can also ask, what can C++ do that cannot be done in VB,Net. You can do it in assembly. You can do it in Rust. The issue is not about what you can do.

    Quote Originally Posted by baka View Post
    Im doing my own GUI, all graphical. animated. I dont use button, listboxes, commandbutton etc. so all those "RAD" component are useless. everything is coding. what can .NET do that I can not do in VB6?
    It's interesting you should mention this. This pet project of mine is actually a nearly full rewrite of a 2D engine I wrote in VB6 previously. Neither versions cared about UI widgets since they were all about the engine itself. However, when I wrote the VB.Net versions, I saw massive benefits in terms of development speed and the greater freedom of expression I had when implementing various components in the engine.

    The biggest and most noticeable advantage actually came in the form of something that could not be done at all in VB6. I wanted a flexible way to describe how various creature would behave. I found a very clever way of doing it in the Doom source code. The monsters in Doom are actually derived from a common base class and derived classes would use something called code pointers in the definition of their behavior. Code pointers were actually a term used by the modding community but they were in actuality function pointers. To create a monster, you derive from a monster base class, you set basic properties like what sprites it uses, how many hit points it has etc. But when it's time to define it's behavior, you would define it as a series of simple instructions like FireProjectile, ChangeDirection, Walk, Sleep, Die etc. These instructions came in the form of function pointers implemented in the base class. It proved to be an extremely flexible yet compact way of creating new monsters. I wanted to do the exact same thing with my stuff because I saw how powerful it was in the Doom source. It's like having your own embedded scripting language without having to actually create a scripting language. I could not do this in VB6 but it could have done it in my VB.Net version. As a result I found that I could create some disgustingly complex behavior for the creatures in my VB.Net version quite easily. To do the same thing in the VB6 version would have required me to develop and entire scripting engine to describe creature behavior, something that would have taken too much valuable time from working on the actual engine.

    Here's an actual example of how I used this technique to define the behavior for one of the creatures in the VB.Net version:-
    Code:
    Public Class GoldenAfrit
        Inherits ComplexCreature
    
        Public Sub New()
            MyBase.New(DemonSprites.GoldAfrit)
        End Sub
    
        Public Overrides ReadOnly Property Species As String
            Get
                Return "Afrit"
            End Get
        End Property
    
        Protected Overrides ReadOnly Property AgilityPercent As Integer
            Get
                Return 40
            End Get
        End Property
    
        Protected Overrides ReadOnly Property FlinchChance As Integer
            Get
                Return 60
            End Get
        End Property
    
        Protected Overrides ReadOnly Property CreatureDefinition As System.Collections.Generic.IList(Of DefinitionExpression)
            Get
                Dim lst As New List(Of DefinitionExpression)
    
                lst.Add(StandardStateLabels.Start)
                lst.Add(New Expr_Exec(Sub() ECMD_Start()))
                lst.Add(New Expr_Frames("fr07", "ABCD", 10, Sub() ECMD_Roam()))
                lst.Add(New Expr_Exec(Sub() ECMD_AttackRandomTarget("PrepAttack", 30)))
    
    
                lst.Add(New Expr_Label("PrepAttack"))
                lst.Add(New Expr_Exec(Sub() ECMD_SetSpeed(Me.TopSpeed * 2)))
                lst.Add(New Expr_Exec(Sub() ECMD_SetFlag(CreatureFlags.GhostMode, True)))
                lst.Add(New Expr_Exec(Sub() ECMD_SetFlag(CreatureFlags.MoveBlur, True)))
                lst.Add(New Expr_Exec(Sub() ECMD_SetDeceleration(0.3)))
                lst.Add(New Expr_Goto("SlowB4Atk"))
    
                lst.Add(New Expr_Label("SlowB4Atk"))
                lst.Add(New Expr_Frames("fr07", "E", 1, Sub() ECMD_FaceAndApproachTarget()))
                lst.Add(New Expr_Exec(Sub() ECMD_JumpIfNotMoving("BeginAttack")))
    
                lst.Add(New Expr_Label("BeginAttack"))
                lst.Add(New Expr_Frames("fr07", "F", 10, Sub() ECMD_FaceTarget()))
                lst.Add(New Expr_Frames("fr07", "G", 10, Sub() ECMD_FaceTarget()))
                lst.Add(New Expr_Exec(Sub() ECMD_FireProjectileFoward(GetType(AfritProjectileExplosive40))))
                lst.Add(New Expr_Exec(Sub() ECMD_ChangeTrajectoryRandom()))
                lst.Add(New Expr_Exec(Sub() ECMD_JumpIfNoTarget("AttackDone")))
                lst.Add(New Expr_Exec(Sub() ECMD_Jump("PrepAttack", 60)))
                lst.Add(New Expr_Goto("AttackDone"))
    
                lst.Add(New Expr_Label("AttackDone"))
                lst.Add(New Expr_Exec(Sub() ECMD_SetFlag(CreatureFlags.GhostMode, False)))
                lst.Add(New Expr_Exec(Sub() ECMD_SetFlag(CreatureFlags.MoveBlur, False)))
                lst.Add(New Expr_Goto(StandardStateLabels.Start.LabelName))
    
                lst.Add(StandardStateLabels.Flinch)
                lst.Add(New Expr_Exec(Sub() ECMD_SetSpeed(0.1)))
                lst.Add(New Expr_Frames("fr07", "H", 10, Sub() ECMD_ChangeTrajectoryRandom()))
                lst.Add(New Expr_Goto(StandardStateLabels.Start.LabelName))
    
                lst.Add(StandardStateLabels.Thrusted)
                lst.Add(New Expr_Frames("fr07", "H", 1, Sub() ECMD_AllowStart()))
                lst.Add(New Expr_Exec(Sub() ECMD_JumpIfNotMoving(StandardStateLabels.Start.LabelName)))
    
    
                lst.Add(StandardStateLabels.Dying)
                lst.Add(New Expr_Frames("fr07", "IJKLMNOPQR", 15))
                lst.Add(New Expr_Exec(Sub() ECMD_RemoveMe()))
    
                Return lst
            End Get
        End Property
    Pay particular attention to the CreatureDefinition property. It's basically a list of instructions describing the creature's behavior in it's various states. Notice the ECMD calls are function calls actually embedded in the definitions. This the exact technique ID Software used in Doom. Doom was written in C++ which has function pointers. Doing this in a language without something akin to function pointers like VB6 would necessitate having to embed those ECMD calls as hard coded text. I would have to write code to parse that myself. They are function calls so I'd not only have to parse them, I'd have to verify the calls, verify the parameters, evaluate expressions, resolve types etc. Just a whole lot of extra work, not to mention that the compiler already does all this. By using function pointers(delegates in .Net), I could have the compiler take care of all those details for me. I won't have to write my own mini-compiler for just this feature. I haven't even mentioned the advantage of having the aid of the intellisense when writing these creature definitions using this technique in VB.Net.
    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 | I'm not wanted

    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

  2. #82
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

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

    Quote Originally Posted by baka View Post
    what can .NET do that I can not do in VB6?
    Get updated.
    My usual boring signature: Nothing

  3. #83
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

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

    I already created monster behavior, created my own functionality using a chance/probability simulator.
    I dont need to copy someone else work. u dont need .NET to make a game either.

    one reason you do programming is the challenges. its fun to figure out things, to create new functions and formulas.
    its half the fun when I create a game. would be boring otherwise. would never copy. I would feel its a steal.
    I could "copy" some boring memory handling function sure, but not, something as important as monster behavior, that part I want to do myself, since that is a big part of the game.

    just because u left VB6 now u think its obsolete, that an update is the next thing.
    but I dont see .NET to be the next thing. not yet. and I dont think never. its not worth it.
    you fail to give me any benefit that I feel are worth it. nothing. u show nothing that is "better".

    the only thing that could make me try it is the 64 and crossplatform features.
    but, theres other languages that seems more "fun" that offers that.

    also kfcSmitty, read the title. or is this some kind of bashing VB6 without consequences thread?

    so, the old old thing I wrote: Perspective. thats the key. you need to know the other person perspective. theres no truth.
    for me theres no obviousness that .NET is the next thing. I would IF I worked in the IT business, like many of you do.
    but Im not. Im in a team making games right now, but nobody is telling us what program to use or not. Im my own master and I decide exactly what I want. its my life and my time.

  4. #84
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

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

    Quote Originally Posted by baka View Post
    also kfcSmitty, read the title. or is this some kind of bashing VB6 without consequences thread?
    Read my post.

    Quote Originally Posted by kfcSmitty View Post
    I'm going to treat this more as a "What do I like about C#" vs "C# VS VB" or anything... these are just some things I like about C#.
    Quote Originally Posted by kfcSmitty View Post
    I should also say I do mostly web-dev and I rarely write a desktop app unless I am making some quick batch job... but those are a few of the things I like about writing in C#.
    Quote Originally Posted by kfcSmitty View Post
    I also want to emphasize, my post is not meant to entice anyone to leave their language of choice. It is meant to point out things I like about my language of choice.
    This is Chit Chat and posts go all over the place. Read each individual post to see their intent, not the title of the thread.

    You're clearly looking for a fight and I'm not going to oblige.

  5. #85
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

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

    Quote Originally Posted by Niya View Post
    If you washed your clothes by hand for 1 year and suddenly you got a washing machine. Will you ever want to go back to washing by hand after using the machine for a year?

    That's how most of us feel about this stuff. What we had before was just fine but once you try some of this new stuff, you just don't want to go back. That's how I got into VB.Net. When I tried it for the first time, I had no idea that I was going to leave VB6. After using it for a while, I just couldn't go back. These new features were just too good. I learned that there is a big difference between reading about something and actually using it. You don't really get it until you give it an honest chance.

    I don't expect you to get it and that's fine. Let each man judge for himself what is good for him. We will just provide the facts.

    Hi Niya,
    just out of interest, can you show some of your VB6 Code and then the change to .NET

    I have made a living with VB over the last decades and still can pay the Bill's. I don't right any new stuff because the old hand washing Code still works. I did start with .Net in 2017, but more out of intrest rather than to make a living from that.
    I do like some features in .Net, but I'm heading for retirement in mabye 2years time at the age of 61.
    so not Bad to be able to do that with the help of all the VB versions there were before .Net came along.

    the vb6 Washingmachine Code I still maintain is to 95% for Applications with Database's, not Games or .....

    EDIT: it should be
    the vb6 Hand Washing Code I still maintain is to 95% for Applications with Database's, not Games or .....



    regards
    chris
    Last edited by ChrisE; Feb 2nd, 2021 at 02:37 AM.
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  6. #86

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by baka View Post
    I already created monster behavior, created my own functionality using a chance/probability simulator.
    I dont need to copy someone else work. u dont need .NET to make a game either.

    one reason you do programming is the challenges. its fun to figure out things, to create new functions and formulas.
    its half the fun when I create a game. would be boring otherwise. would never copy. I would feel its a steal.
    I could "copy" some boring memory handling function sure, but not, something as important as monster behavior, that part I want to do myself, since that is a big part of the game.
    I didn't copy anybody's code. I copied a programming technique from John Carmack.

    I think I'm starting to understand why you say the things you say. I'm not a 100% sure if I'm right about you but if you'll indulge me I'd like to ask you a question. Do you know C/C++? Do you know assembly language?

    To be clear, I'm not asking whether you have ever written programs in C/C++ or assembly I'm just asking if you have any understanding these languages. Like if I posted a short snippet of C code would you be able to read it and understand what is happening at a glance?
    Last edited by Shaggy Hiker; Feb 2nd, 2021 at 10:12 AM. Reason: Trimmed the snark, to try to dampen the flames.
    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 | I'm not wanted

    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

  7. #87
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by ChrisE View Post
    the vb6 Washingmachine Code I still maintain is to 95% for Applications with Database's, not Games or .....

    EDIT: it should be
    the vb6 Hand Washing Code I still maintain is to 95% for Applications with Database's, not Games or .....
    Nah - you got it right the first time (no need for your "Edit").

    There definitely is Washingmachine Code available for VB6 - especially when it comes to Data-Handling.

    And it's not really "the language itself" which provides larger code-savings - it's libraries.

    For example, when you take kfcSmitty's stuff - you can easily save Code-Lines in VB6 with proper Recordset-Objects
    (no matter if from the DAO, ADO or RC5/6-libs):

    E.g. his:
    var nissanCars = carList.Where(b => b.Brand == "Nissan");

    ... is doable with the ADO-lib via:
    rsCars.Filter = "Brand = 'Nissan'"

    Or the "existence-check":
    if(carList.Any(car => car.Brand == "Nissan") {
    // we have a nissan in stock!
    }

    ... is doable e.g. with the RC5-cRecordset (Find-Methods being available in DAO and ADO as well) via:
    If rsCars.FindFirst("Brand = 'Nissan'") Then
    ' we have a nissan in stock
    End If

    Besides,... one could of course always just Select the right amount of "filtered set-records" from the DB via proper SQL in the first place.

    Olaf

  8. #88

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by ChrisE View Post
    Hi Niya,
    just out of interest, can you show some of your VB6 Code and then the change to .NET

    I have made a living with VB over the last decades and still can pay the Bill's. I don't right any new stuff because the old hand washing Code still works. I did start with .Net in 2017, but more out of intrest rather than to make a living from that.
    I do like some features in .Net, but I'm heading for retirement in mabye 2years time at the age of 61.
    so not Bad to be able to do that with the help of all the VB versions there were before .Net came along.

    the vb6 Washingmachine Code I still maintain is to 95% for Applications with Database's, not Games or .....

    EDIT: it should be
    the vb6 Hand Washing Code I still maintain is to 95% for Applications with Database's, not Games or .....



    regards
    chris
    I think I know where you're going with this. The first page of this thread does show some direct comparisons between development in VB6 and Visual Studio 2019(VB.Net, C#, WPF etc.)

    However, you can't really think of it in such terms. It's not really about what someone can do in the one that they can't do in the other. It's more about the development experience. Anything you can do in VB.Net you can do in VB6 but the question is how much does the tool help you to bring your ideas into reality. I'll rehash a simple example I did once before. Take this piece of XAML code:-
    Code:
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.Resources>
                                <SolidColorBrush x:Key="color" Color="{Binding}"/>
                            </StackPanel.Resources>
    
                            <Rectangle Height="40" Width="40" Fill="{StaticResource color}"/>
    
                            <TextBlock Foreground="{StaticResource color}" VerticalAlignment="Center">How it looks as text</TextBlock>
                            <Button Margin="25,0,0,0" Width="70" VerticalAlignment="Center" Click="Button_Click">Remove</Button>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
    The above code modifies a ComboBox to do this:-


    Can that be done in VB6? Sure it can, but will it be that simple? I'd say probably not. Just placing a Button inside the ComboBox is a technical challenge and I'm sure if I spent a few hours I can figure out how to do it or I could wait for someone like Krool to show me how. But I really don't want to spend my time on such a simple UI detail and I don't want to have to wait on someone in a forum to answer my question on how to do it. I just want to get it done and move on. WPF's XAML layout engine makes it easy to accomplish things like 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 | I'm not wanted

    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

  9. #89

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    Besides,... one could of course always just Select the right amount of "filtered set-records" from the DB via proper SQL in the first place.
    You can use LINQ to query lists and collections directly without the need for an entire database engine to provide the querying infrastructure.
    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 | I'm not wanted

    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. #90
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    I copied a programming technique from John Carmack.
    In the worst possible way...

    Or can you point out exactly, why you didn't implement "specific behaviour":
    - behind a normal ISpecialBehaviour_Behave() method
    - using normal Code

    Please don't try to explain "higher order functions" to me again - I use them all the time in js.

    I'm just saying that you've implemented your "special behaviour" in the "most overcomplicated way posssible".

    Olaf

  11. #91
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    You can use LINQ to query lists and collections directly without the need for an entire database engine to provide the querying infrastructure.
    Which of course raises the question, where the data in your Collections came from in the first place.

    Olaf

  12. #92
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

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

    Quote Originally Posted by Schmidt View Post
    Which of course raises the question, where the data in your Collections came from in the first place.

    Olaf
    Web services, NoSQL, (file, network, whatever) streams...

  13. #93
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    Code:
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <StackPanel.Resources>
                                <SolidColorBrush x:Key="color" Color="{Binding}"/>
                            </StackPanel.Resources>
    
                            <Rectangle Height="40" Width="40" Fill="{StaticResource color}"/>
    
                            <TextBlock Foreground="{StaticResource color}" VerticalAlignment="Center">How it looks as text</TextBlock>
                            <Button Margin="25,0,0,0" Width="70" VerticalAlignment="Center" Click="Button_Click">Remove</Button>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
    The above code modifies a ComboBox to do this:-


    Can that be done in VB6? Sure it can, but will it be that simple?
    Of course it can be as simple.

    Two different ways come immediately to mind.
    1) - use a DataRepeater-Control
    2) - use a VirtualList-Control (which then has roughly the same amount of code in its OwnerDrawItem-method as your XAML-block)

    As for WPF - I'm of the same opinion as slzmany... the easy things work well - but as soon as it gets a bit more complex, then you start to struggle.

    Don't believe me?

    Try to re-implement this VB6-Code (only about 50 lines) via VB.NET and WPF:

    Requirements:
    - a virginal VB6-Form-Project
    - with two normal VB6-Controls on it (a TextBox named: txtCurved and a CheckBox named: chkFitToCurve)
    - and a reference to the (newest) RC6-lib (version >= 6.0.3)
    - finally paste the Code below into the Form
    Code:
    Option Explicit
     
    Private WithEvents Panel As cWidgetForm, WithEvents Canvas As cwCanvas
    
    Private Sub Form_Load()
      Set Panel = Cairo.WidgetForms.CreateChild(hWnd)
          'Panel.WidgetRoot.Zoom = 2
      Set Canvas = Panel.Widgets.Add("cwCanvas", "Canvas")
      Set Canvas.BGPattern = Cairo.CreateCheckerPattern
          Canvas.RenderControlPoints = True
      
      Rnd -9 'init the Random-Generator with always the same seed
      Dim i As Long
      For i = 1 To 7 'add 7 controlpoints to our Canvas (y-Pos gets randomized)
        Canvas.ControlPoints.Add "P" & i, (i - 1) * 90 + 50, 30 + Rnd * 350, IIf(i = 1 Or i = 7, vbGreen, vbBlue), 7
      Next
    End Sub
    
    Private Sub Form_Resize() 'resize the Panel
      ScaleMode = vbPixels: Panel.Move 0, 30, ScaleWidth, ScaleHeight - 30
    End Sub
    Private Sub Panel_ResizeWithDimensionsDIP(ByVal dx As Double, ByVal dy As Double)
      Canvas.Widget.Move 0, 0, dx, dy 'resize the sole Panel-Child (the Canvas-Widget) in turn
    End Sub
    
    Private Sub txtCurved_Change()
      Canvas.Widget.Refresh
    End Sub
    Private Sub chkFitToCurve_Click()
      Canvas.Widget.Refresh
    End Sub
     
    Private Sub Canvas_Paint(CC As cCairoContext, ByVal dx As Double, ByVal dy As Double)
      CC.SetLineWidth 4 'ensure the best Line-Prop- and Antialias-settings for Text-Path-Rendering
      CC.SetLineCap CAIRO_LINE_CAP_ROUND
      CC.SetLineJoin CAIRO_LINE_JOIN_ROUND
       
      Dim PArr As cArrayList, CP As cControlPoint
      Dim CurvePath As cCairoPath, CurveLength As Double, CurveDists() As Double
      Dim TextPath As cCairoPath, TextWidth As Double
       
      'ensure a BSpline-Poly via copy-over from the ControlPoint-Coords into a consecutive Double-Array
      Set PArr = New_c.ArrayList(vbDouble)
      For Each CP In Canvas.ControlPoints: PArr.Add CP.x: PArr.Add CP.y: Next
    
      'create just the "pure" BSpline-Path (no filling and no stroking - only the Path-Coords)...
      CC.PolygonPtr PArr.DataPtr, PArr.Count \ 2, False, splNormal, True
        Set CurvePath = CC.CopyPath(True, 0.005) '...copy the (flattened) path from the CC...
      CC.ClearPath '...and clear the Path from the CC
      
      'same here, only the pure TextPath (the Coords) is getting copied (no filling)
      CC.SelectFont "Times New Roman", 20
      CC.TextOut 0, -3, txtCurved.Text, True, 1, True '<- the last Param ensures "Path-only" rendering
        Set TextPath = CC.CopyPath()
      CC.ClearPath
      
      CC.AppendPath CurvePath  'now the Path is back again on the Cairo-Context
      CC.Stroke False, Cairo.CreateSolidPatternLng(vbRed) 'so we Stroke (drawing the Line-Color along the path)
      
      'Here's where the transformation of the TextPath-Coords happens (via projection from the Base-Coords of 'CurvePath')
      '(with a small precalculation, to achieve a Text-Fitting to the Curve-Length if the User wants that)
      TextWidth = CC.GetTextExtents(txtCurved.Text)
      CurveLength = IIf(chkFitToCurve, CurvePath.CalculateDistances(CurveDists), TextWidth)
      If TextWidth > 0 Then TextPath.ProjectPathData_Using CurvePath, CurveLength / TextWidth
      
      'the now finished Coord-Projection was performed directly on the TextPath-Objects-internal Coords-Array...
      CC.AppendPath TextPath
      CC.Fill False, Cairo.CreateSolidPatternLng(&H202020)
    End Sub
    What you then get is an interactive Demo (where you can change the ControlPoint-Position to manipulate the Curve):


    Olaf

  14. #94
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by peterst View Post
    Web services, NoSQL, (file, network, whatever) streams...
    NoSQL? ... please let's not go there...

    Files (instead of DBs to hold your "collection-like" data)? ... please let's not go there as well

    What remains (Web services (network, whatever) streams) ...
    can be aggregated into: "RPC-results"

    Which raises the question again - what did you do at the serverside of these RPCs.

    I can return ADO- or RC5/RC6-Recordsets directly from my (Web-)RPCs just fine.

    Olaf

  15. #95

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    Or can you point out exactly, why you didn't implement "specific behaviour":
    - behind a normal ISpecialBehaviour_Behave() method
    - using normal Code
    This way of doing it is extremely inflexible. John Carmack's technique basically allows you to script creature behavior very freely by defining the behavior as a series of simpler instructions implemented as function pointers.

    Quote Originally Posted by Schmidt View Post
    I'm just saying that you've implemented your "special behaviour" in the "most overcomplicated way posssible".
    The alternative way of doing it would be to embed the instructions as text and parsing it myself, a far more arduous task.
    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 | I'm not wanted

    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. #96
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

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

    Quote Originally Posted by Schmidt View Post
    NoSQL? ... please let's not go there...

    Files (instead of DBs to hold your "collection-like" data)? ... please let's not go there as well

    What remains (Web services (network, whatever) streams) ...
    can be aggregated into: "RPC-results"

    Which raises the question again - what did you do at the serverside of these RPCs.

    I can return ADO- or RC5/RC6-Recordsets directly from my (Web-)RPCs just fine.

    Olaf
    So you tell me to discard all NoSQL databases we are using in production?
    You tell me to discard all log analyzers?
    Discard what whole world is using except VB6-ers?

    Thank you. Good bye. Good luck in your journey!

  17. #97
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

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

    Quote Originally Posted by Schmidt View Post
    NoSQL? ... please let's not go there...

    Files (instead of DBs to hold your "collection-like" data)? ... please let's not go there as well

    What remains (Web services (network, whatever) streams) ...
    can be aggregated into: "RPC-results"

    Which raises the question again - what did you do at the serverside of these RPCs.

    I can return ADO- or RC5/RC6-Recordsets directly from my (Web-)RPCs just fine.

    Olaf
    The point with Linq is that I can use NoSQL (which has some good use cases), I can use files (when appropriate), databases, webservices, in memory collections, etc. and abstract out the underlying mechanisms. I can pretty much query them in the same way regardless of the underlying implementation. It becomes a single approach to working with a lot of different implementations.

  18. #98

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    (which then has roughly the same amount of code in its OwnerDrawItem-method as your XAML-block)
    If you remember where I got that from, you'd also remember I did an DrawItem version in WinForms. It's certainly wasn't as simple. It wasn't that much code but it did require a lot more focus on details such as doing layout calculations. We had this discussion before.

    Quote Originally Posted by Schmidt View Post
    As for WPF - I'm of the same opinion as slzmany... the easy things work well - but as soon as it gets a bit more complex, then you start to struggle.

    Don't believe me?

    Try to re-implement this VB6-Code (only about 50 lines) via VB.NET and WPF:

    Requirements:
    - a virginal VB6-Form-Project
    - with two normal VB6-Controls on it (a TextBox named: txtCurved and a CheckBox named: chkFitToCurve)
    - and a reference to the (newest) RC6-lib (version >= 6.0.3)
    - finally paste the Code below into the Form
    That is quite impressive. No lie.

    However, you don't choose WPF to do stuff like that. WPF makes certain UI tasks a lot easier to accomplish than it would be in WinForms or VB6. You see the greatest benefits when your needs are relatively modest. Embedding buttons in a ComboBox is a pretty modest need that doesn't require any kind of real effort to implement in WPF.
    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 | I'm not wanted

    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

  19. #99
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by peterst View Post
    So you tell me to discard all NoSQL databases we are using in production?
    No - if you find them useful vehicles to store your data - go ahead.

    Whereas I'll stick to the relational approach (which is in no way "out-dated" or "a thing of the past").

    <shrug>
    It's a "religious topic" (no matter what language you're using) - hence my "let's not go there"...)

    Quote Originally Posted by peterst View Post
    You tell me to discard all log analyzers?
    No - but "a log-file" requires parsing in the first place.
    And it's the result of that parsing-routine, which either:
    - hands you a collection
    - or hands you an InMemory-DB-Object or a Recordset

    Quote Originally Posted by peterst View Post
    Discard what whole world is using except VB6-ers?
    Not sure what you mean with "the whole world".
    Just in case you meant NoSQL-datastorage - I have to strongly disagree - only a small part of "the world" is using that approach to persistence.

    Quote Originally Posted by peterst View Post
    Thank you. Good bye. Good luck in your journey!
    Thank you as well, always glad to help...

    Olaf

  20. #100

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    Files (instead of DBs to hold your "collection-like" data)? ... please let's not go there as well
    There are times when a database engine is overkill.
    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 | I'm not wanted

    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

  21. #101
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    That is quite impressive. No lie.

    However, you don't choose WPF to do stuff like that.
    WPF makes certain UI tasks a lot easier ...
    Whereas the "classic approach" (a good drawing-lib + a good Control-engine) can make *all* GUI-tasks easier
    (no matter how complex).

    Olaf

  22. #102
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    There are times when a database engine is overkill.
    Not if it's a small one, which is part of your framework already
    (as e.g. SQLite, which only contributes 500KB to the RC6-package).

    An SQLite InMemory-DBs can completely replace most LINQ-scenarios:
    - with far better performance
    - and powerful Query-expression-support, based on a Standard-Language (SQL)

    Olaf

  23. #103

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    No - if you find them useful vehicles to store your data - go ahead.

    Whereas I'll stick to the relational approach (which is in no way "out-dated" or "a thing of the past").
    I think the point he is making is that LINQ makes it unnecessary to depend on the backend implementation. Basically he is talking about a design philosophy called separation of concerns. LINQ would give you querying power on the front end regardless of what is on the back end. You could have hamsters feeding you the data and you could still query it in the front end. The advantage here is that you could slap in whatever backend you want without having to make any significant change to your front end.
    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 | I'm not wanted

    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

  24. #104
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by PlausiblyDamp View Post
    ...I can use files (when appropriate)...
    It becomes a single approach to working with a lot of different implementations.
    Linq (basically) needs "Objects with named Properties" which are aggregated in a List
    (which then is not different from "Records with named Fields, which are aggregated in a table").

    So, I do the same here - but my single approach (to working with records),
    is to transform them into a Table (either InMemory or Persistent) already in the Parsing-stage.

    For example, if you point out a link to a larger log-file - you could show me:
    - your LINQ-based filter-approach (on a parsed Collection which holds the Log-records)
    - and I'll show you an SQLite- based approach
    After that let's compare notes, which implementation needed less code -
    and which one produced a filtered result faster.

    Olaf

  25. #105
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

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

    Quote Originally Posted by Schmidt View Post
    Not if it's a small one, which is part of your framework already
    (as e.g. SQLite, which only contributes 500KB to the RC6-package).

    An SQLite InMemory-DBs can completely replace most LINQ-scenarios:
    - with far better performance
    - and powerful Query-expression-support, based on a Standard-Language (SQL)

    Olaf
    Or I could use Linq with an in memory database, as part of the built in framework, often with comparable performance.

    Linq provides a lot more than just querying databases, the fact you get intellisense, compile time validation, strongly typed objects - these all make for an easier development cycle.

  26. #106
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    I think the point he is making is that LINQ makes it unnecessary to depend on the backend implementation. Basically he is talking about a design philosophy called separation of concerns. LINQ would give you querying power on the front end regardless of what is on the back end. You could have hamsters feeding you the data and you could still query it in the front end. The advantage here is that you could slap in whatever backend you want without having to make any significant change to your front end.
    You are missing the point, who is producing these Collection-like lists.
    They are Objects somebody needs to build at the clientside
    (because what you get from a remote-call is either a binary- or a text-stream).

    It is at that point, where you can decide what you want to "materialize" (deserialize) the stream-content into.

    I've already tried to get you to come up with an example for a "log-file-filter" in #104.

    Feel free to contribute the .NET version.

    Olaf

  27. #107

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    - with far better performance
    We don't use LINQ for it's performance. We use it for it's convenience. It's a readily available querying infrastructure that's baked directly into the Framework and is even supported directly by the language. It's all about convenience. We use it all the time for even the simplest tasks where performance is not a concern.
    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 | I'm not wanted

    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. #108

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by PlausiblyDamp View Post
    Linq provides a lot more than just querying databases, the fact you get intellisense, compile time validation, strongly typed objects - these all make for an easier development cycle.
    Exactly.
    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 | I'm not wanted

    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. #109
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

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

    Quote Originally Posted by Niya View Post
    I think the point he is making is that LINQ makes it unnecessary to depend on the backend implementation. Basically he is talking about a design philosophy called separation of concerns. LINQ would give you querying power on the front end regardless of what is on the back end. You could have hamsters feeding you the data and you could still query it in the front end. The advantage here is that you could slap in whatever backend you want without having to make any significant change to your front end.
    I do like Linq which is powerfull, I don't think there is much diffrence if you create a ADO RS on the fly and then query that

    Linq sample
    Code:
     Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
         
            Dim fromDate As DateTime = New DateTime(2017, 10, 24, 17, 2, 12)
            Dim toDate As DateTime = New DateTime(2017, 10, 26, 18, 47, 58)
            Dim xName As String = ComboBox1.Text
    
            'Query
            Dim results = (From line In File.ReadAllLines("D:\xyz.csv").Skip(1) _
                    Let fields = line.Split(New Char() {";"c}).AsEnumerable() _
                    Where DateTime.Parse(fields.ElementAt(1)) > fromDate AndAlso _
                          DateTime.Parse(fields.ElementAt(1)) < toDate AndAlso _
                          fields.ElementAt(0) = xName Select fields).ToArray()
    
           
            'Debug output
            For Each element In results
    
                Debug.WriteLine(element(0) & " : " _
                              & element(1) & " : " _
                              & element(2) & " : " _
                              & element(3) & " : " _
                              & element(4) & " : " _
                              & element(5))
            Next
        End Sub
    ADO create RS to hold Data
    Code:
    Public Property Let FileNameRecordSet(ByVal vData As String)
        mvarFileNameRecordSet = vData
    End Property
    
    Public Property Get FileNameRecordSet() As String
        FileNameRecordSet = mvarFileNameRecordSet
    End Property
    
    Public Function RsCreate() As Boolean
          On Error GoTo Fehler
          With Rs.Fields
             .Append "AD_ID", adInteger
             .Append "AD_Name", adVarChar, 35
             .Append "AD_LastName", adVarChar, 35
             .Append "AD_Birthdate", adDate
             'add more
          End With
          Rs.Open
          Rs.Save FileNameRecordSet
          
          IsChanged = True
          RsCreate = True
          Exit Function
          
    Fehler:
          FehlerAnzeige Err.Number, Err.Description, "RsCreate"
    End Function
    or create a Datatable in .Net to hold the Data and query
    or....
    or....

    there must be XX way's to get a result, so what's the best way ? I would go with Frank Sinatra... I did it my way... https://www.youtube.com/watch?v=qQzdAsjWGPg
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  30. #110

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by Schmidt View Post
    You are missing the point, who is producing these Collection-like lists.
    They are Objects somebody needs to build at the clientside
    (because what you get from a remote-call is either a binary- or a text-stream).

    It is at that point, where you can decide what you want to "materialize" (deserialize) the stream-content into.

    I've already tried to get you to come up with an example for a "log-file-filter" in #104.

    Feel free to contribute the .NET version.

    Olaf
    This is a good point but the thing is if a simple list, array or collection would do then why should we be forced to deserialize the data into something else just to be able to query it. This is the convenience of LINQ. We can just dump it into a boring old array or collection and run our query against 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 | I'm not wanted

    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. #111
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by ChrisE View Post
    ...there must be XX way's to get a result,...
    Right, there are... (and each one requiring roughly the same LOC, if your "washingmachine-libs" are well-implemented).

    Quote Originally Posted by ChrisE View Post
    so what's the best way ?
    If there's several (similar efforts requiring) approaches - then why not go with the one that offers the best performance?
    (And I guess even the .NETers know, how a performance-comparison will turn out).

    Olaf

  32. #112
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    We can just dump it into a boring old array or collection and run our query against that.
    You still don't understand (maybe you'll do, when you implement the little "challenge" I've described in #104).

    The amount of code-lines you need (for "dumping" your parsed "log-line-parts" into a collection-like list) -
    roughly equals the code-lines I need (for "dumping" the parsed parts into an SQLite-InMemory-Table).

    Olaf

  33. #113
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

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

    Quote Originally Posted by Schmidt View Post
    Right, there are... (and each one requiring roughly the same LOC, if your "washingmachine-libs" are well-implemented).



    If there's several (similar efforts requiring) approaches - then why not go with the one that offers the best performance?
    (And I guess even the .NETers know, how a performance-comparison will turn out).

    Olaf
    LOL, you mean "hand washing-libs"
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  34. #114
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

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

    Quote Originally Posted by Schmidt View Post
    You are missing the point, who is producing these Collection-like lists.
    They are Objects somebody needs to build at the clientside
    (because what you get from a remote-call is either a binary- or a text-stream).

    It is at that point, where you can decide what you want to "materialize" (deserialize) the stream-content into.

    I've already tried to get you to come up with an example for a "log-file-filter" in #104.

    Feel free to contribute the .NET version.

    Olaf
    My previous reply was before I saw you asking for an example.

    Just knocked up a quick one using a file I had on my hard drive from some benchmarks I was running
    Code:
    Imports System
    Imports LINQtoCSV
    
    Module Program
        Sub Main(args As String())
            Dim inputFileDescription As New CsvFileDescription With {
                    .SeparatorChar = ","c,
                    .FirstLineHasColumnNames = True
            }
            Dim cc As New CsvContext()
            Dim demo As IEnumerable(Of SampleFile) =
                    cc.Read(Of SampleFile)("sample.csv", inputFileDescription)
    
            Dim results = From d In demo Where d.Measurement_Nanoseconds >= 73992200
                          Order By d.Measurement_Nanoseconds Descending
                          Select New With {.Time = d.Measurement_Nanoseconds / 1000, d.Measurement_Value, d.Measurement_Nanoseconds}
    
            For Each x In results
                Console.WriteLine($"time ns {x.Measurement_Nanoseconds}, Time ms{x.Time}, Value {x.Measurement_Value}")
            Next
        End Sub
    End Module
    
    Public Class SampleFile
        Public Property Target As String
        Public Property Target_Namespace As String
        Public Property Target_Type As String
        Public Property Target_Method As String
        Public Property Job_Id As String
        Public Property Job_AnalyzeLaunchVariance As String
        Public Property Job_EvaluateOverhead As String
        Public Property Job_MaxAbsoluteError As String
        Public Property Job_MaxRelativeError As String
        Public Property Job_MinInvokeCount As String
        Public Property Job_MinIterationTime As String
        Public Property Job_OutlierMode As String
        Public Property Job_Affinity As String
        Public Property Job_EnvironmentVariables As String
        Public Property Job_Jit As String
        Public Property Job_Platform As String
        Public Property Job_PowerPlanMode As String
        Public Property Job_Runtime As String
        Public Property Job_AllowVeryLargeObjects As String
        Public Property Job_Concurrent As String
        Public Property Job_CpuGroups As String
        Public Property Job_Force As String
        Public Property Job_HeapAffinitizeMask As String
        Public Property Job_HeapCount As String
        Public Property Job_NoAffinitize As String
        Public Property Job_RetainVm As String
        Public Property Job_Server As String
        Public Property Job_Arguments As String
        Public Property Job_BuildConfiguration As String
        Public Property Job_Clock As String
        Public Property Job_EngineFactory As String
        Public Property Job_NuGetReferences As String
        Public Property Job_Toolchain As String
        Public Property Job_IsMutator As String
        Public Property Job_InvocationCount As String
        Public Property Job_IterationCount As String
        Public Property Job_IterationTime As String
        Public Property Job_LaunchCount As String
        Public Property Job_MaxIterationCount As String
        Public Property Job_MaxWarmupIterationCount As String
        Public Property Job_MinIterationCount As String
        Public Property Job_MinWarmupIterationCount As String
        Public Property Job_RunStrategy As String
        Public Property Job_UnrollFactor As String
        Public Property Job_WarmupCount As String
        Public Property Job_Display As String
        Public Property Params As String
        Public Property Measurement_LaunchIndex As Integer
        Public Property Measurement_IterationMode As String
        Public Property Measurement_IterationStage As String
        Public Property Measurement_IterationIndex As Integer
        Public Property Measurement_Nanoseconds As Integer
        Public Property Measurement_Operations As Integer
        Public Property Measurement_Value As Double
        Public Property Gen_0 As Integer
        Public Property Gen_1 As Integer
        Public Property Gen_2 As Integer
        Public Property Allocated_Bytes As Integer
    End Class
    The class was generated online using a few lines from the csv, the CsvFileDescription is from a free open source library and the rest of the code is a rough example of how I can do a linq query. Not the results from the query are using an anonymous type so I am not required to create a separate class for every single result I want to project into

  35. #115

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

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

    Quote Originally Posted by ChrisE View Post
    I don't think there is much diffrence if you create a ADO RS on the fly and then query that
    Don't you think it's more convenient to just use normal collections and arrays. I mean look how simple this is:-
    Code:
            For Each btn As Button In Me.Controls.OfType(Of Button).Where(Function(b) Not b.Enabled)
                '''
            Next
    The above is simple common everyday LINQ. That filters out all disabled Buttons on a Form. Do I really need an ADO Recordset 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 | I'm not wanted

    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. #116
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

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

    Quote Originally Posted by Schmidt View Post
    Right, there are... (and each one requiring roughly the same LOC, if your "washingmachine-libs" are well-implemented).



    If there's several (similar efforts requiring) approaches - then why not go with the one that offers the best performance?
    (And I guess even the .NETers know, how a performance-comparison will turn out).

    Olaf
    Unless the performance difference is significant I would go for the easier to read and write option every time. If performance is an issue (proven by benchmarking) then a more performance targeted version makes sense. However the performance impact of tools like Linq can often be minimal.

  37. #117
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

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

    Quote Originally Posted by Schmidt View Post
    Besides,... one could of course always just Select the right amount of "filtered set-records" from the DB via proper SQL in the first place.
    Lots of times having data in memory is faster and more practical.

    Quick basic example: hangman. You have a list of letters the user has chosen. I can easily do chosenLetters.Any(letter => letter == usersChosenletter); to see if they've already selected that letter. No database in sight.

    Another example is a game: most of the time games will store the user's inventory in memory. Perhaps I want to open a door that requires a key.. so now I can easily search the inventory to see if the key exists or not.

    I'm sure there are a ton of other examples, but there are plenty of times where data is loaded into memory and then filtered or queried from there.

    Again, my post isn't to compare to VB6. It looks like VB6 does not have this functionality unless you're using a database, but obviously someone could write their own LINQ for VB6, the same way someone had to write it for .NET.

  38. #118
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by Niya View Post
    Don't you think it's more convenient to just use normal collections and arrays. I mean look how simple this is:-
    Code:
            For Each btn As Button In Me.Controls.OfType(Of Button).Where(Function(b) Not b.Enabled)
                '''
            Next
    The above is simple common everyday LINQ. That filters out all disabled Buttons on a Form. Do I really need an ADO Recordset for that?
    No, you could simply write it this way:
    Code:
    For Each Ctl in Me.Controls
      If TypeOf Ctl Is Button Then
        If Not Ctl.Enabled Then ...
      End If
    Next
    It's roughly the same amount of Chars to type, as in your example.
    Code:
    For Each btn As Button In Me.Controls. _
       OfType(Of Button)._
          Where(Function(b) Not b.Enabled)
                '''
    Next
    Olaf

  39. #119
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

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

    Quote Originally Posted by Niya View Post
    Don't you think it's more convenient to just use normal collections and arrays. I mean look how simple this is:-
    Code:
            For Each btn As Button In Me.Controls.OfType(Of Button).Where(Function(b) Not b.Enabled)
                '''
            Next
    The above is simple common everyday LINQ. That filters out all disabled Buttons on a Form. Do I really need an ADO Recordset for that?
    you got me Lost ? my sample(s) was regarding to query a File
    not to query Controls

    if I want to know Values from Controls, I would do it this way

    in a Modul:
    Code:
    'Module -------------------------------
    
    Option Explicit
    
    
    Public Type ObjInfoType
       Name     As String
       Value    As String
       Type     As String
       Default  As Boolean
    End Type
    
    Public Function GetPropsFromObject(obj As Object) As ObjInfoType()
        Dim mb      As Members
        Dim mbi     As MemberInfo
        Dim objInfo() As ObjInfoType
       
        Dim ci      As ConstantInfo
        Dim ciVbr   As ConstantInfo
        Dim TI      As TypeLibInfo
        Dim mi      As MemberInfo
        Dim vt      As TliVarType
        
        Dim i       As Long
        Dim dvt     As Long
        Dim v       As Variant
        
        On Error Resume Next
        
        Set TI = TLI.TLIApplication.TypeLibInfoFromFile("tlbinf32.dll")
        For Each ci In TI.Constants
            If ci.Name = "TliVarType" Then Exit For
        Next ci
        
        Set TI = TypeLibInfoFromFile("msvbvm60.dll\3")
        Set mb = InterfaceInfoFromObject(obj).Members
        ReDim objInfo(mb.Count)
        
        For Each mbi In mb
             If mbi.InvokeKind And INVOKE_PROPERTYGET Then
                If mbi.MemberId = 0 Then
                    dvt = mbi.VTableOffset
                Else
                    objInfo(i).Name = mbi.Name
                    If mbi.VTableOffset = dvt Then objInfo(i).Default = True
                With mbi.ReturnType
                    vt = .VarType
                    If .TypeInfo Is Nothing Then
                        For Each mi In ci.Members
                            If vt = mi.Value Then objInfo(i).Type = mi.Name: Exit For
                        Next mi
                        v = vbEmpty
                        v = CallByName(obj, mbi.Name, VbGet)
                        If vt = VT_BSTR Then
                            objInfo(i).Value = """" & v & """"
                        ElseIf vt = VT_I2 Then
                            objInfo(i).Value = v
                            For Each ciVbr In TI.Constants
                                If ciVbr.TypeKind = TKIND_ENUM Then
                                    If ciVbr.Name = mbi.Name & "Constants" Then
                                        For Each mi In ciVbr.Members
                                            If mi.Value = v Then
                                                objInfo(i).Value = v & " (" & _
                                                    mi.Name & ")"
                                                    Exit For
                                            End If
                                        Next mi
                                        Exit For
                                    End If
                                End If
                            Next ciVbr
                        Else
                            objInfo(i).Value = v
                        End If
                    Else
                        objInfo(i).Type = "OBJ(" & .TypeInfo.Parent.Name & "." & _
                            .TypeInfo.Name & ")" & " GUID" & .TypeInfo.Guid
                        Set v = CallByName(obj, mbi.Name, VbGet)
                        If v Is Nothing Then
                            objInfo(i).Value = "Nothing"
                        Else
                            objInfo(i).Value = "PTR(&H" & _
                                Right$("0000000" & Hex$(ObjPtr(v)), 8) & ")"
                        End If
                    End If
                End With
                
                i = i + 1
                End If
             End If
        Next mbi
          
        ReDim Preserve objInfo(i - 1)
        On Error GoTo 0
        GetPropsFromObject = objInfo()
    End Function
    'existiert eine bestimmte Property bei einem Object
    Public Function ExistObjectProp(obj As Object, PropName As String) As Boolean
    
       Dim objInfo() As ObjInfoType
       Dim i As Long
    
          objInfo() = GetPropsFromObject(obj)
          For i = LBound(objInfo) To UBound(objInfo)
             If UCase(objInfo(i).Name) = UCase(PropName) Then
                ExistObjectProp = True
                Exit Function
             End If
          Next
    End Function
    and in a Form
    Code:
    Private Sub Command1_Click()
    
       Dim i As Long
       Dim objInfo() As ObjInfoType
       Dim ctl As Control
       
          For Each ctl In Me.Controls
             Debug.Print vbCrLf & "--------------" & ctl.Name
             objInfo = GetPropsFromObject(ctl)
             For i = LBound(objInfo) To UBound(objInfo)
                Debug.Print objInfo(i).Name & " = " & objInfo(i).Value
             Next
          Next
    End Sub
    the debug Output
    Code:
    --------------Timer1
    Name = "Timer1"
    Index = 0
    Enabled = Wahr
    Interval = 0
    Parent = PTR(&H009C9928)
    Tag = ""
    
    --------------Command2
    Name = "Command2"
    Caption = "Command2"
    Index = 0
    BackColor = -2147483633
    Left = 1125
    Top = 1275
    Width = 1590
    Height = 540
    Enabled = Wahr
    Visible = Wahr
    MousePointer = 0 (vbDefault)
    FontName = "MS Sans Serif"
    FontSize = 8,25
    FontBold = Falsch
    FontItalic = Falsch
    FontStrikethru = Falsch
    FontUnderline = Falsch
    TabIndex = 1
    Value = Falsch
    Default = Falsch
    Cancel = Falsch
    Parent = PTR(&H009C9928)
    DragMode = 0 (vbManual)
    DragIcon = PTR(&H0098B950)
    TabStop = Wahr
    Tag = ""
    hWnd = 1313338
    HelpContextID = 0
    MouseIcon = PTR(&H0098B950)
    Font = PTR(&H0715CF5C)
    WhatsThisHelpID = 0
    Appearance = 1
    Container = 
    RightToLeft = Falsch
    Picture = PTR(&H0098B950)
    DisabledPicture = PTR(&H0098B950)
    DownPicture = PTR(&H0098B950)
    ToolTipText = ""
    OLEDropMode = 0
    MaskColor = 12632256
    UseMaskColor = Falsch
    Style = 0
    CausesValidation = Wahr
    
    --------------Command1
    Name = "Command1"
    Caption = "Command1"
    Index = 0
    BackColor = -2147483633
    Left = 975
    Top = 450
    Width = 1740
    Height = 615
    Enabled = Wahr
    Visible = Wahr
    MousePointer = 0 (vbDefault)
    FontName = "MS Sans Serif"
    FontSize = 8,25
    FontBold = Falsch
    FontItalic = Falsch
    FontStrikethru = Falsch
    FontUnderline = Falsch
    TabIndex = 0
    Value = Wahr
    Default = Falsch
    Cancel = Falsch
    Parent = PTR(&H009C9928)
    DragMode = 0 (vbManual)
    DragIcon = PTR(&H0098B950)
    TabStop = Wahr
    Tag = ""
    hWnd = 788370
    HelpContextID = 0
    MouseIcon = PTR(&H0098B950)
    Font = PTR(&H05E8C034)
    WhatsThisHelpID = 0
    Appearance = 1
    Container = 
    RightToLeft = Falsch
    Picture = PTR(&H0098B950)
    DisabledPicture = PTR(&H0098B950)
    DownPicture = PTR(&H0098B950)
    ToolTipText = ""
    OLEDropMode = 0
    MaskColor = 12632256
    UseMaskColor = Falsch
    Style = 0
    CausesValidation = Wahr
    
    --------------Label1
    Name = "Label1"
    Caption = "Label1"
    Index = 0
    BackColor = -2147483633
    ForeColor = -2147483630
    Left = 2550
    Top = 5850
    Width = 1740
    Height = 315
    Enabled = Wahr
    Visible = Wahr
    MousePointer = 0 (vbDefault)
    FontName = "MS Sans Serif"
    FontSize = 8,25
    FontBold = Falsch
    FontItalic = Falsch
    FontStrikethru = Falsch
    FontUnderline = Falsch
    TabIndex = 6
    BorderStyle = 0 (vbTransparent)
    Alignment = 0 (vbLeftJustify)
    LinkTopic = ""
    LinkItem = ""
    LinkMode = 0 (vbLinkNone)
    AutoSize = Falsch
    Parent = PTR(&H009C9928)
    DragMode = 0 (vbManual)
    DragIcon = PTR(&H0098B950)
    LinkTimeout = 50
    Tag = ""
    WordWrap = Falsch
    BackStyle = 1
    DataField = ""
    DataChanged = Falsch
    MouseIcon = PTR(&H0098B950)
    UseMnemonic = Wahr
    Font = PTR(&H05E8C10C)
    WhatsThisHelpID = 0
    Appearance = 1
    Container = 
    RightToLeft = Falsch
    ToolTipText = ""
    OLEDropMode = 0
    DataMember = ""
    DataFormat = PTR(&H05E9BEC0)
    DataSource = Nothing
    
    DataMember = ""
    DataFormat = PTR(&H070FFE10)
    DataSource = Nothing
    more Lines of Code, but got every Value of the control(s)
    Last edited by ChrisE; Feb 2nd, 2021 at 08:08 AM.
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  40. #120
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

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

    Quote Originally Posted by kfcSmitty View Post
    Another example is a game: most of the time games will store the user's inventory in memory.
    Perhaps I want to open a door that requires a key.. so now I can easily search the inventory to see if the key exists or not.
    So, why not "hold" the Game-settings (including the "users inventory") in an InMemory-DB?

    To create an InMem-DB-Object is a OneLiner.
    (and there's several convenience-methods, to "push" structured data into such an Object as a new Table).

    And to retrieve filtered Lists (in the form of "Recordset-DataContainers") is just "another line of code".

    Olaf

Page 3 of 24 FirstFirst 12345613 ... 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