-
Oct 26th, 2021, 03:51 AM
#761
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by dday9
Realistically I'd use an existing library for this (see my Bootstrap codebank submission) but for something quick and dirty like this I figured I'd just do it in each iteration.
Did you know that you could omit 4 lines of that code? Namely the radius.AddLines. It's possible because CloseFigure automatically closes any gaps in the path by adding straight lines.
BB
Last edited by boops boops; Oct 26th, 2021 at 03:55 AM.
-
Oct 29th, 2021, 05:26 PM
#762
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Source:-
VB6
Code:
Option Explicit
Private Type MyUdtType
TheName As String
Data() As Long
End Type
Private MyUdt() As MyUdtType
Private Sub Form_Load()
ReDim MyUdt(1 To 2)
ReDim MyUdt(1).Data(1 To 5)
MyUdt(1).TheName = "Hyundai"
MyUdt(1).Data(1) = 0
MyUdt(1).Data(2) = 0
MyUdt(1).Data(3) = 14
MyUdt(1).Data(4) = 5
MyUdt(1).Data(5) = 0
ReDim MyUdt(2).Data(1 To 5)
MyUdt(2).TheName = "Tata"
MyUdt(2).Data(1) = 10
MyUdt(2).Data(2) = 0
MyUdt(2).Data(3) = 0
MyUdt(2).Data(4) = 20
MyUdt(2).Data(5) = 5
End Sub
VB.Net
Code:
Private Class MyUdtType
Public TheName As String
Public Data() As Long
End Class
Private myUdt As MyUdtType()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myUdt = {New MyUdtType With {.TheName = "Hyundai", .Data = {0, 0, 14, 5, 0}},
New MyUdtType With {.TheName = "Tata", .Data = {10, 0, 0, 20, 5}}}
End Sub
-
Oct 30th, 2021, 01:45 PM
#763
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
I thought we were done with this.
Anyways, that's not a great conversion. Sure, the .NET is really compact, but it's a bad design. Data shouldn't be an array of long, it probably should be a Dictionary(of Integer, Integer). That's one of the points about the comparison: The languages are simply different. You'd design the same thing differently.
My usual boring signature: Nothing
-
Oct 30th, 2021, 04:03 PM
#764
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
I thought we were done with this.
Yeah, ... <sigh>
Originally Posted by Shaggy Hiker
The languages are simply different. You'd design the same thing differently.
Exactly.
Here is (as always, shorter) VB6-code, which fullfills the requirement as well.
Code:
Private CarInfo As New cSortedDictionary
Private Sub Form_Load()
CarInfo.Add "Hyundai", New_c.ArrayList(vbLong, 0, 0, 14, 5, 0)
CarInfo.Add "Tata", New_c.ArrayList(vbLong, 10, 0, 0, 20, 5)
End Sub
@Niya
Is this some new tactics now, to spelunk through the forums VB6-codesnippets -
until you find something you think is easier to formulate in .NET?
I could do that too, you know... e.g. with the "blinking-label" here...(you might know the author).
.NET-code:
Code:
#region "BlinkLabel"
public class BlinkLabel : Label
{
private System.Windows.Forms.Timer g_objTimer = new System.Windows.Forms.Timer();
private int g_iBlinkTime = 0;
private bool g_bVisible = true;
private bool g_bIsBlinking = false;
private bool g_bDefaultVisible = true;
[System.ComponentModel.DefaultValue(true)]
public new bool Visible {
get { return g_bDefaultVisible; }
set {
g_bDefaultVisible = value;
if (base.DesignMode == true) {
base.Visible = true;
} else {
base.Visible = value;
}
if (g_bDefaultVisible == true & g_bIsBlinking == true) {
g_objTimer.Interval = g_iBlinkTime;
g_objTimer.Enabled = true;
//Remove any previous handlers
g_objTimer.Tick -= Elapsed;
g_objTimer.Tick += Elapsed;
}
if (g_bDefaultVisible == false & g_bIsBlinking == true) {
g_objTimer.Enabled = false;
g_objTimer.Tick -= Elapsed;
}
}
}
[System.ComponentModel.DefaultValue(0)]
public int BlinkTime {
get { return g_iBlinkTime; }
set {
g_iBlinkTime = value;
if (base.DesignMode == false) {
if (g_iBlinkTime != 0) {
//If the control's visible property is false
//go into blink mode but dont show the control
if (g_bDefaultVisible == true) {
g_objTimer.Interval = g_iBlinkTime;
g_objTimer.Enabled = true;
g_objTimer.Tick += Elapsed;
}
g_bIsBlinking = true;
} else {
g_objTimer.Enabled = false;
g_objTimer.Tick -= Elapsed;
base.Visible = g_bDefaultVisible;
g_bIsBlinking = false;
}
}
}
}
private void Elapsed(object sender, System.EventArgs e)
{
if (g_bVisible)
g_bVisible = false;
else
g_bVisible = true;
base.Visible = g_bVisible;
}
}
#endregion
VB6-code (to be pasted into an ucBlink-Control):
Code:
Private WithEvents tBlink As VB.Timer
Public Sub StartBlinking(C As Control, Optional Interval% = 500)
If tBlink Is Nothing Then Set tBlink = Controls.Add("VB.Timer", "tBlink")
StopBlinking
tBlink.Interval = Interval: tBlink.Tag = C.Name & IIf(C.Visible, "|", "")
End Sub
Public Sub StopBlinking()
Dim v, n: v = InStr(tBlink.Tag, "|"): n = Replace(tBlink.Tag, "|", "")
If Len(n) Then Parent.Controls(n).Visible = v: tBlink.Tag = ""
End Sub
Private Sub tBlink_Timer()
Dim n: n = Replace(tBlink.Tag, "|", "")
If Len(n) Then Parent.Controls(n).Visible = Not Parent.Controls(n).Visible
End Sub
Wow, VB6 needs a 6-times smaller code-volume, compared to .NET...
(so, I guess that makes it at least 12 times as good, since I'm biased, you know...)
Olaf
-
Oct 30th, 2021, 06:17 PM
#765
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Ha! You went to C# to find that. Classic! Well done.
However, you're using string fiddling to make it smaller. That's my objection to LINQ, too: Yes, it's smaller, but it performs worse.
Also, the two aren't quite the same, and you appear to have done some fairly disingenuous things in there, though Niya also did a few things that were kind of unnecessary. I have no idea why he wrote that event handler like that. It should have been two lines, and possibly only one.
My usual boring signature: Nothing
-
Oct 31st, 2021, 03:39 AM
#766
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
However, you're using string fiddling to make it smaller.
Yes - it's as messy as the C# version (but look at the code-size <g>).
FWIW, here is another version, which avoids the String-fiddling (even saving a line):
Code:
Private WithEvents tBlink As VB.Timer, CName As String, VOrig As Boolean
Public Sub StartBlinking(C As Control, Optional Interval% = 500)
If tBlink Is Nothing Then Set tBlink = Controls.Add("VB.Timer", "tBlink")
StopBlinking
tBlink.Interval = Interval: CName = C.Name: VOrig = C.Visible
End Sub
Public Sub StopBlinking()
If Len(CName) Then Parent.Controls(CName).Visible = VOrig: CName = ""
End Sub
Private Sub tBlink_Timer()
If Len(CName) Then Parent.Controls(CName).Visible = Not Parent.Controls(CName).Visible
End Sub
Originally Posted by Shaggy Hiker
Also, the two aren't quite the same, ...
Yep, despite having less code - the VB6-version even works generically -
(it can make any VB-Control blink on a given Form, not only Labels).
Olaf
-
Oct 31st, 2021, 10:28 AM
#767
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
Yep, despite having less code - the VB6-version even works generically -
(it can make any VB-Control blink on a given Form, not only Labels).
Olaf
That's not really a valid point. What Niya was doing was creating a new type of label that blinked. That would end up in the toolbox and could be used anywhere that had a reference. Had he been trying to create a blinking control, it wouldn't be using the code shown. So, it's not necessarily either an advantage or disadvantage that the code you have will blink any control. Sure, it's true, but so what, since that wasn't what Niya was trying to do in the code shown. One could point out the advantage of your approach, as you did, but there's an advantage to his approach, too, which is that you now have a new tool that can be dragged and dropped onto the form. Which one is better depends on what your ultimate objective is. Each is better in one particular case....and to be fair, blinking controls are totally obnoxious, so the real question is: Which is more evil?
My usual boring signature: Nothing
-
Oct 31st, 2021, 11:23 AM
#768
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
- but I love a nice blinkenlighten.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Oct 31st, 2021, 11:51 AM
#769
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
I have no idea why he wrote that event handler like that. It should have been two lines, and possibly only one.
I wrote that class when I was still in the process of learning .Net. Also, that code was generated by a tool, converted from VB.Net.
Another thing, this was back in 2012. While I still have a lot of bad programming habits today, I had a lot more then. Interestingly enough, I took a lot of inspiration from Olaf over the years to improve some of my shortcomings. But like I said, I still have many.
Last edited by Niya; Oct 31st, 2021 at 11:58 AM.
-
Oct 31st, 2021, 12:01 PM
#770
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
I thought we were done with this.
You're right. I think my approach has been the wrong one. Words cannot seem to describe what I see in my mind.
I'm working on something that should take this whole debate in a new direction. Even I don't know what the results would be yet but when it's done, hopefully everyone would see what I was trying to say for 20 pages now.
-
Oct 31st, 2021, 12:06 PM
#771
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
Yeah, ... <sigh>
Exactly.
Here is (as always, shorter) VB6-code, which fullfills the requirement as well.
Code:
Private CarInfo As New cSortedDictionary
Private Sub Form_Load()
CarInfo.Add "Hyundai", New_c.ArrayList(vbLong, 0, 0, 14, 5, 0)
CarInfo.Add "Tata", New_c.ArrayList(vbLong, 10, 0, 0, 20, 5)
End Sub
@Niya
Is this some new tactics now, to spelunk through the forums VB6-codesnippets -
until you find something you think is easier to formulate in .NET?
I have an interesting question.....why didn't Elroy do this? Why is is that you seem to be the only one in your camp writing code like this in VB6? Obviously this way is more compact, easier to understand, less error prone and less typing. There is no reason code like this shouldn't be common on your side of the fence yet it isn't. You have produced equally compact VB6 examples of code I posted in VB.Net all throughout this thread but the rest of the community is still doing things the "hard" way. Why is that?
I suspect I know what the answer is but I'd like to know what you think.
-
Oct 31st, 2021, 12:53 PM
#772
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by yereverluvinuncleber
- but I love a nice blinkenlighten.
You found the exception to the rule...sort of. Technically, even on a display like that, a blinking light is there to grab your attention. You might say that it is TRYING to be obnoxious. In this case, it serves it's purpose, and the more important the information, the more obnoxious it should be.
Though, personally, I find the occulting light equally eye-catching, and far more visually pleasing. You might consider that approach.
My usual boring signature: Nothing
-
Oct 31st, 2021, 12:56 PM
#773
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
I suspect I know what the answer is but I'd like to know what you think.
I know why, and I'm REALLY not sure I want to hear what Olaf is willing to say on the subject. As if VB6 vs VB.NET isn't enough of a kerfuffle for one thread. Do you really need to add an even more bitter one?
My usual boring signature: Nothing
-
Oct 31st, 2021, 01:12 PM
#774
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
I have an interesting question.....why didn't Elroy do this?
I don't know... Copy&Multiplying a dozen of identical lines (then correcting a few differences),
is not really "slow" - (when preparing some Dummy-Inputs to demonstrate something).
Also, Elroy is not an RC5/6-User (not familiar with these framework-classes I used in my demo).
And "including an alternative Dictionary-Reference" from another System-provided COM-lib,
takes a few seconds as well... (the Copy&Multiply+ Replace probably more convenient).
Those willing to include the MS-Dictionary, could have written it in a similar way (without RC5):
Code:
Private CarInfo As New Scripting.Dictionary
Private Sub Form_Load()
CarInfo.Add "Hyundai", Array(0, 0, 14, 5, 0)
CarInfo.Add "Tata", Array(10, 0, 0, 20, 5)
Dim Brand 'enumerate the Brands (and associated Arr-Data)
For Each Brand In CarInfo
Debug.Print Brand, Join(CarInfo(Brand), ", ")
Next
End Sub
Generally, there's also a kind of "Class-phobia" many VB6-Hobbyists have... <shrug>
When you start out in VB6, it's quite easy to avoid Classes (besides "visible Forms and Controls") completely -
(which is not really possible in .NET, when "everything is an Object")... and thus OO-concepts are "never approached".
Olaf
-
Oct 31st, 2021, 01:47 PM
#775
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
I know why, and I'm REALLY not sure I want to hear what Olaf is willing to say on the subject. As if VB6 vs VB.NET isn't enough of a kerfuffle for one thread. Do you really need to add an even more bitter one?
Why do you think this would be contentious? It is a valid question. I don't see a lot of people writing VB6 code the way he does and I would genuinely like to know why.
As for what I suspect is the answer, it is a lack of an official documentation. There were many times on these forums I want to write something in VB6 and I think of RC5/6 but then I get turned off the because I really don't look forward to drudging through the depth of the forum looking for samples on how to do something in RC5/6.
Originally Posted by Schmidt
Generally, there's also a kind of "Class-phobia" many VB6-Hobbyists have... <shrug>
When you start out in VB6, it's quite easy to avoid Classes (besides "visible Forms and Controls") completely -
(which is not really possible in .NET, when "everything is an Object")... and thus OO-concepts are "never approached".
Olaf
This is also very valid. Pushing the potential arguments about imperative vs OO programming aside, this is very true. VB6 programmers really do seem allergic to classes. I too was like this. It was towards the end of my time in VB6 did I really start appreciating OO programming and it was one of the major contributing factors to my adoption of .Net. It suited my way of reasoning about code and algorithms perfectly. I have also developed an appreciation for functional style programming in recent years. My love of LINQ is proof of this.
-
Oct 31st, 2021, 07:06 PM
#776
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
As for what I suspect is the answer, it is a lack of an official documentation.
If you are really serious about the RC6, then you don't need any such thing.
(since the VB6-IDE has Intellisense and the VB6-ObjectExplorer, which documents all the Classes and Methods).
The Class-Methods (and their Args) are "selfdocumenting" enough - or compatible to existing Objects
(like e.g. cCollection being compatible to VB.Collection, cRecordset 95% compatible with ADO-Recordsets a.s.o.)
Since you like Lists and similar container-classes - just make a little test with the following code...
and then tell me, whether the intellisense leaves you unsatisfied when it comes to Method-Params.
I hope you know all the VB6-Intellisense-tricks (setting the caret into a given Param-list, then pressing <Space>)...
Same for the Obj-Explorer ...(F2, or <Shift>+F2 when you have the caret placed within a MethodName)
Code:
Private SD As cSortedDictionary
Private Sub Form_Load()
Set SD = New_c.SortedDictionary(TextCompare) 'New_c offers constructor-methods
SD.Add "Saab", New_c.ArrayList(vbLong, 4, 3, 2, 6, 5)
SD.Add "Audi", New_c.ArrayList(vbLong, 3, 2, 0, 1, 4)
SD.Add "Fiat", New_c.ArrayList(vbLong, 5, 4, 3, 2, 1)
Dim K As String, V As cArrayList, i As Long
For Each V In SD
K = SD.KeyByIndex(i): i = i + 1 'the Key-Value-pairs of an SD come in already sorted "by definition"
V.Sort 'just for fun, we sort the Value-Array before printing
Debug.Print K, V.Join(",") 'print the sorted Keys along with the sorted Values
Next
End Sub
And just in case it is the New_c -"thingy" which throws you off...
This Symbol is directly available, after the lib-reference check-in took place (it doesn't have to be declared) -
and it acts as the Root-object for the whole RC6-Class-Namespace, so to say...
offering constructor-methods for all available RC-Classes - along with useful optional Params.
Would like it, when you'd make use of it in your next VB6-challenge...
Olaf
Last edited by Schmidt; Oct 31st, 2021 at 07:10 PM.
-
Nov 1st, 2021, 06:51 PM
#777
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
If you are really serious about the RC6, then you don't need any such thing.
(since the VB6-IDE has Intellisense and the VB6-ObjectExplorer, which documents all the Classes and Methods).
The Class-Methods (and their Args) are "selfdocumenting" enough - or compatible to existing Objects
(like e.g. cCollection being compatible to VB.Collection, cRecordset 95% compatible with ADO-Recordsets a.s.o.)
Since you like Lists and similar container-classes - just make a little test with the following code...
and then tell me, whether the intellisense leaves you unsatisfied when it comes to Method-Params.
I hope you know all the VB6-Intellisense-tricks (setting the caret into a given Param-list, then pressing <Space>)...
Same for the Obj-Explorer ...(F2, or <Shift>+F2 when you have the caret placed within a MethodName)
Oh this is a good thing, yes that is true. But it is still not enough. The intellisense/object explorer are great for simpler classes and methods and it's also great to remind people who are already familiar with said classes and methods on how they work. However, it is not enough for any near mastery of the library or someone who is completely unfamiliar with the library.
You know what's great about .Net? How every single class and method is documented. All their nuances are described, all the potential pitfalls illuminated. Here is an example from your library where the lack of documentation falls short, cArrayList.BindToArray. What does that do? How do I go about finding out what it does? What does it's parameter do? I can guess that it's meant to take a normal VB6 array and use it as the cArrayList instance's internal data store. Assuming I'm right, how does it do it? Does it copy the array or only a pointer? Also, what if my guess is wrong and it does something completely different?
Now there is a way to find out, I can spend 10 to 15 minutes testing it and it would answer some questions. But wouldn't it have been better if there was a nice little piece of documentation on it I could spend 1 to 2 minutes reading to learn instead. And there are things testing cannot reveal about a library in short order. There are things only the author of a library could possible know.
A good example of this is the Bitmap class in .Net. When a Stream object is used to create a Bitmap in .Net, the Stream object must not be closed as long as the Bitmap is being used. It is not something that would be obvious from use. In fact it is entirely possible to use the Bitmap class for years without ever noticing this behavior but when it does break someone's program and they are wondering why, it won't take long to discover this in the documentation:-
You must keep the stream open for the lifetime of the Bitmap.
And on that same page there is another piece of nuance:-
Due to a limitation of the GDI+ decoder, an System.ArgumentException is thrown if you construct a bitmap from a .png image file with a single dimension greater than 65,535 pixels.
Source here. This is why documentation for standard libraries is extremely important. I think this is the biggest thing standing in the way of mass adoption by the VB6 community at large.
I've seen all the objects in RC6 through the object explorer and sad to say, I don't have a clue what 90% of it does. Let's look at some of them.
cAttribute
What is it? What does it do? What classes is it meant to work with?
cAuth
It obviously has something to do with authorization for web content but exactly how? Where is it meant to be used?
cDataBase
Obviously has something to do with databases but what kind? Does it work with Sql Server? Can it work with any data provider? How do I go about populating it? Can it deal with stored procedures?
cFactory
What does that do? The only clue is the method RegFree which I can guess has something to do with registration free COM but that guess could be totally wrong.
cControlPoint
Based on the names of it's methods and properties, it has something to do with drawing controls but where? How do I use this class? What does the PositionChanging event do? Does it fire when a control is being moved? Would it fire if the control is moved by code or only by using the mouse? How do I hook up this event to a Control?
cControlInterface
Based on the name it has something to do with interfaces and Controls but where does it fit? What service does it provide that relates to interfaces and Controls? What does GetName do? Does it get the name of the Control or the name of some interface implemented by the Control class?
........
Do you see what I mean? There is just way too much information missing that the intellisense and object browser doesn't account for. If you type the name of any and I mean any class in .Net Core of the .Net Framework, you will get all the information you need to get it working and to diagnose bugs caused by misuse. And in nearly all cases you also get sample code that demonstrates their use. You cannot underestimate the value of this. This is by far the biggest advantage .Net has over RC5/6.
-
Nov 1st, 2021, 06:55 PM
#778
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Yeah. I've been working on something for VSTO in Word, and am finding the documentation severely lacking or just plain wrong. Good documentation makes things SO much easier. Good documentation is pretty doggone hard to do, too. MS did well with .NET, but their system is a bit difficult to use (though it ends up with good results if you write with discipline). Unfortunately, their documentation on some things, like VSTO, are decidedly worse than the documentation on .NET.
My usual boring signature: Nothing
-
Nov 1st, 2021, 07:17 PM
#779
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
Yeah. I've been working on something for VSTO in Word, and am finding the documentation severely lacking or just plain wrong. Good documentation makes things SO much easier. Good documentation is pretty doggone hard to do, too. MS did well with .NET, but their system is a bit difficult to use (though it ends up with good results if you write with discipline). Unfortunately, their documentation on some things, like VSTO, are decidedly worse than the documentation on .NET.
It's far from perfect. I had the same problem when I was learning about writing robust custom controls in .Net. The Wizard Control in my signature is an example of such a control. I remember that being very difficult to write because of a lack of detailed documentation in this area. I had to discover a lot by trial and error. I don't blame MS for this because, well....no one is perfect. They still tend provide very high quality documentation overall but I don't expect they would cover everything perfectly. The Windows platform is so vast and ever changing that it would be a miracle if everything was documented perfectly. Still though, it is extremely frustrating trying to do something without proper documentation.
-
Nov 2nd, 2021, 12:27 PM
#780
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
Here is an example ...
cArrayList.BindToArray. What does that do?
You approach the whole documentation-thing backwards, just to have an excuse for your own "peace of mind", it seems.
Because here I try to find "additional info" (about some method) only when it is needed...
(e.g. I've never googled the MS-Documentation for their "Scripting.Dictionary",
because Intellisense did tell me everything I needed to know with regards to .Add, .Exists, Remove, .Count etc.)
And the same thing goes for the cArraylist-Methods (as .Add, .Remove, .Sort, .Item, etc.)...
they are self-documenting enough to be usable even by an RC6-Newbie.
As for the other Classes you have listed, they are all Child-Classes, which you reach only when "going deeper" on a given Object.
(the Main-Classes are the ones, which you can instantiate via New_c (Methods, contained in cConstructor).
To give an example for that...
You want to parse an XML-DOM and want to use the RC6.SimpleDOM-Class to do that.
So you write a simple test like the following, starting with a "With construct" on the Main-Entry-Class
(as said - those reachable behind New_c are the Main-Entry-Classes into certain "topics"):
Code:
With New_c.SimpleDOM("<rec id='1'><fld name='x'>1.1</fld><fld name='y'>2.2</fld></rec>")
Debug.Print .Root.TagName, .Root.Attributes("id").Text
Dim E As cElement
For Each E In .Root.ChildElements
Debug.Print " "; E.Attributes("name").Text, E.Text
Next
End With
printing out:
In the above code:
- the purple Attributes-Method is obviously of type cAttributes (your typical list-class with .Count and .Item)
- for the blue part, intellisense tells you, that the param-name of the left out Item-method is: IndexZeroBasedOrName
- and finally the cyan .Text is listed by intellisense as being part of the cAttribute-interface
So - in the context of the just given example:
If you want to read something *before-starting an implementation*,
you should google about XML in general if you are new to the topic.
Getting familiar with terms like "Node", or "Element" - and e.g. learn that an Element can have multiple "Attributes".
*Now* you start writing an implementation (and will not have to contact any "Method-documentation",
since Intellisense will pop-out all these now familiar sounding terms, you read before on Wikipedia.
IMO the whole topic of the "missing RC6-Docu" gets "over-dramatised" a lot.
The RichClient is one of the libs with the most example-coverage on the inter-webs
(including extensive, VB6-code-based tutorials for SQLite and Cairo).
Olaf
Last edited by Schmidt; Nov 2nd, 2021 at 12:38 PM.
-
Nov 2nd, 2021, 12:35 PM
#781
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Here's how you would do the same thing in VB.NET:
Code:
Dim xml As XElement = <rec id='1'>
<fld name='x'>1.1</fld>
<fld name='y'>2.2</fld>
</rec>
Console.WriteLine("{0}, {1}", xml.Name, xml.Attribute("id").Value) ' rect, 1
Console.WriteLine(String.Join(" ", xml.Elements.Select(Function(e) e.Attribute("name").Value))) ' x y
Edit - I've also noticed that you like to compress your code on single lines (e.g. using the line join (:) character, minifying the XML, etc.), not sure if this is actually your coding style (in which case I'd argue against it) or if you're doing it in this thread to deliberately make your code as concise as possible, but you can also keep the XML literal minified if you so wish:
Code:
Dim xml As XElement = <rec id='1'><fld name='x'>1.1</fld><fld name='y'>2.2</fld></rec>
Console.WriteLine("{0}, {1}", xml.Name, xml.Attribute("id").Value) ' rect, 1
Console.WriteLine(String.Join(" ", xml.Elements.Select(Function(e) e.Attribute("name").Value))) ' x y
Last edited by dday9; Nov 2nd, 2021 at 02:24 PM.
-
Nov 2nd, 2021, 01:20 PM
#782
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by dday9
Here's how you would do the same thing in VB.NET:
Code:
Dim xml As XElement = <rec id='1'>
<fld name='x'>1.1</fld>
<fld name='y'>2.2</fld>
</rec>
Console.WriteLine("{0}, {1}", xml.Name, xml.Attribute("id").Value) ' rect, 1
Console.WriteLine(String.Join(" ", xml.Elements.Select(Function(e) e.Attribute("name").Value))) ' x y
I would also point out that this is probably one of the few areas where VB.Net or rather Microsoft's VB.Net compiler is superior to C#. I don't think even to this day C# supports XML literals.
-
Nov 2nd, 2021, 01:31 PM
#783
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
It does not. I believe it is because of C#'s syntax and use of arrows. E.g., there would be ambiguity between XML literals and this:
Code:
var foo = new List<string>();
-
Nov 2nd, 2021, 02:23 PM
#784
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
-
Nov 2nd, 2021, 03:06 PM
#785
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
You approach the whole documentation-thing backwards, just to have an excuse for your own "peace of mind", it seems.
Are you actually suggesting that my desire for clear and detailed documentation is a bad thing? I'm honestly surprised that you of all people would think this way. I know you have a wealth of knowledge about the Win32 API and COM in particular and I seriously doubt you learned all of this without reading a single MSDN document.
Originally Posted by Schmidt
Because here I try to find "additional info" (about some method) only when it is needed...
(e.g. I've never googled the MS-Documentation for their "Scripting.Dictionary",
because Intellisense did tell me everything I needed to know with regards to .Add, .Exists, Remove, .Count etc.)
And the same thing goes for the cArraylist-Methods (as .Add, .Remove, .Sort, .Item, etc.)...
they are self-documenting enough to be usable even by an RC6-Newbie.
Arrays, collections, lists, queues, stacks, hash tables, dictionaries, and linked lists are all standard language agnostic data structures. They don't need to be documented for experienced programmers. The intellisense and object browser would suffice in this case.
Originally Posted by Schmidt
IMO the whole topic of the "missing RC6-Docu" gets "over-dramatised" a lot.
I'm just gonna be straight with you. I think you're making a big mistake in underestimating the need for documenting a large library like this. It's not that people can't figure out it on their own, it's that the world has already set the standard for this kind of thing. I mean look at the Win32 API. It's nearly fully documented. You look up Java's standard libraries and you would find the same thing. .Net, jQuery, HTML, CSS, these are all fully documented. People don't have to guess and experiment to find out what something does or how it works. You cannot seriously expect people in 2021 to not want some kind of documentation for a library. This is the standard practice in 2021. If you want your library to be competitive, you have to make it less intimidating to approach.
Originally Posted by Schmidt
As for the other Classes you have listed, they are all Child-Classes, which you reach only when "going deeper" on a given Object.
(the Main-Classes are the ones, which you can instantiate via New_c (Methods, contained in cConstructor).
To give an example for that...
You want to parse an XML-DOM and want to use the RC6.SimpleDOM-Class to do that.
So you write a simple test like the following, starting with a "With construct" on the Main-Entry-Class
(as said - those reachable behind New_c are the Main-Entry-Classes into certain "topics"):
Code:
With New_c.SimpleDOM("<rec id='1'><fld name='x'>1.1</fld><fld name='y'>2.2</fld></rec>")
Debug.Print .Root.TagName, .Root.Attributes("id").Text
Dim E As cElement
For Each E In .Root.ChildElements
Debug.Print " "; E.Attributes("name").Text, E.Text
Next
End With
printing out:
In the above code:
- the purple Attributes-Method is obviously of type cAttributes (your typical list-class with .Count and .Item)
- for the blue part, intellisense tells you, that the param-name of the left out Item-method is: IndexZeroBasedOrName
- and finally the cyan .Text is listed by intellisense as being part of the cAttribute-interface
All of this is obvious to you because you wrote it. It is not so obvious to me. cAttributes could be anything. Are you saying you expect me to spend the time doing all that detective work to figure out where cAttributes is meant to be used all on my own from the little clues provided by the intellisense and the object browser?
Ok lets explore that. cAttributes has an Item property of cAttribute. If I then follow to cAttribute, I would see the various DOM-like properties including the ParentElement property of type cElement. If I follow to cElement I would see a set of properties and methods that make it obvious these classes are about the XML DOM. But now I'm stuck. Where do I go from here? There is nothing here to indicate that I need to build an XML DOM using the cSimpleDOM class.
Now you're right in that it can be figured out but again I refer you to my previous point, no other popular library would hoist this responsibility upon potential users. They would provide samples and documentation for this. Here is the point I think you're missing. Documentation saves time. It saves me the time from having to tinker around in the library trying to figure out how everything is related to each other. Going back to cSimpleDOM, it could take me anywhere from 15 minutes to 1 hour to discover that cAttributes, cElement, cAttribute etc are all meant to be used with the cSimpleDOM class. And we haven't even mentioned all the time it takes to bump around from one class to another checking each property and method for clues. Come on man. We can't be doing things this way in 2021.
Here's the thing. I get it. You're one person. You cannot be expected to write the library and detailed documentation too. That is just too much for one man. However, this doesn't change the fact documentation is important for standard libraries meant for the public. I would expect that you at least have some kind of plan to document it in the future, even if you're going to hire someone else to do it. I'm telling you, this is essential. You cannot ignore this. You're underestimating how frustrating it is to use a library that is undocumented.
-
Nov 2nd, 2021, 05:09 PM
#786
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
Are you actually suggesting that my desire for clear and detailed documentation is a bad thing?
Of course not - but please don't create drama, where there is no need.
Originally Posted by Niya
Arrays, collections, lists, queues, stacks, hash tables, dictionaries, and linked lists are all standard language agnostic data structures. They don't need to be documented for experienced programmers. The intellisense and object browser would suffice in this case.
See, that's the only thing I wanted to point out to you...
In your VB6-examples you've deliberately avoided the usage of especially these more enhanced containers,
with the excuse of "this lib is unusable for me, when there's no documentation".
Originally Posted by Niya
...cAttributes could be anything.
No, it couldn't.
It is "publically not creatable" (and also not part of what the New_c contructor is able to hand out to you.)
The only way you encounter this, is:
"as a Property behind an enumerated (XML) cElement-type as cElement.Attributes" -
where it immediately makes sense to any experienced developer, who knows "the basics of XML"
(without consulting a documentation).
So yes, an "official documentation" is missing for the RC... but as said: don't "over-dramatise",
because again: there are extensive source-code based tutorials for the more complex things in the RC-lib.
I always preferred to study "new things with tutorial-based Project-Code" (real-life-examples),
compared to studying "dry documentation".
BTW... @dday9
The XML-example was not meant as "another challenge".
I'm not of the opinion, that VB6 is "more efficient, coding-wise" compared with .NET.
(though I also don't think, that the opposite is true - a small, but noticable difference to Niya).
VB6 *does* have certain advantages over .NET - but these are technical ones (not ones related to coding-productivity).
Instead the example was meant for Niya, to make it clear to him, that when implementing concrete stuff with the RC6-Classes,
all the "Sub-ClassTypes" (as e.g. cAttributes->cAttribute via cAttributes.Item) explain themselves via Intellisense
(as well as from the current coding-context of the Parent-Object they are located behind as a Property).
That's stuff even hobbyists are aware of, when they worked for a few weeks with e.g. ADO or DAO-Recordsets.
When a PropertyName is named "in plural" (like e.g. Rs.Fields), then you can expect:
- a .Count Property behind it
- as well as an .Item-Property, which is usually the default in the COM-world
- and can therefore left out for stuff like Rs.Fields("ID").Value
Back to Niya (another tip for the VB6-ObjectExplorer) in this regard:
If you place the caret to the "left side of the dot" this way: Rs.Fields("ID")|.Value -
and then press <Shift><F2>, the ObjExpl will link you to the Properties of the Fields-Class.
If you place it to the "right side of the dot" this way: Rs.Fields("ID").|Value -
and then press <Shift><F2>, the ObjExpl will link you to the Properties of the Field-Class.
<Ctrl><F4> will close the Object-Explorer again - and you're back in the Code.
HTH
Olaf
-
Nov 2nd, 2021, 06:02 PM
#787
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
The XML-example was not meant as "another challenge".
I'm not of the opinion, that VB6 is "more efficient, coding-wise" compared with .NET.
(though I also don't think, that the opposite is true - a small, but noticable difference to Niya).
VB6 *does* have certain advantages over .NET - but these are technical ones (not ones related to coding-productivity).
Am I mistaken or isn't that the crux of Niya's argument?
-
Nov 2nd, 2021, 07:17 PM
#788
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by dday9
Am I mistaken or isn't that the crux of Niya's argument?
Not sure what you mean exactly.
For any decent developer, there's two parts to "keep apart" (when it comes to such comparisons):
1. Productivity (the coding-part)
- Trying to compare this, is childish in the extreme ... because there's nothing to compare really.
(when we talk about professional devs, it all boils down to "libs and dev-experience" -
the language becomes secondary - and with enough experience the productivity is about the same).
2. Tech-advantages (of the final output - as well as "political ones")
- Here there's clear differences one can observe or measure...
2.1 for VB6+COM these would be (basically):
--- smaller binaries (as e.g. factor 30 smaller framework-size for VB6)
--- faster startup-times (up to factor 50, compared with larger .NET-Apps, no "hot-compilation from MSIL" is needed)
--- more deterministic behaviour with regards to memory-freeing (no Garbage-Collector)
2.2 for .NET these would be (basically):
--- more "future proof" (not having the "it's abandoned stain" on it)
--- and therefore you have "more job offers", targeting .NET-languages
--- easier to implement "multi-language capabilities" due to MSIL and operating "VM-based"
What Niya "imagines" though is, that he has a "huuuge" productivity advantage -
though he fails to produce a midsized real-world example, which clearly shows that this is the case...
...we had these discussions for years already - and he's never shown anything .NET-based with a "Wow-factor".
Olaf
Last edited by Schmidt; Nov 2nd, 2021 at 07:22 PM.
-
Nov 2nd, 2021, 08:08 PM
#789
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
...we had these discussions for years already - and he's never shown anything .NET-based with a "Wow-factor".
Olaf
With any sufficiently capable language, you can do...pretty nearly anything, so there's only one feature of .NET that has a Wow-factor: The 11th edition is in beta. So, the most important advantage that .NET has over VB6 is that it is being continuously updated by one of the most valuable companies in the world.
My usual boring signature: Nothing
-
Nov 2nd, 2021, 08:32 PM
#790
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Shaggy Hiker
....With any sufficiently capable language, you can do...pretty nearly anything....
I'm sure Photoshop could be written in pure assembly yet no one would do that. Capability by itself means nothing if you don't also factor in productivity and the truth is, for the same capabilities, modern versions of Visual Studio along with .Net and the various development templates like WPF, ASP.Net, WinForms etc are far more productive than VB6. This is the point. I've tried to show why but I think what has been lost in translation so to speak is that everything co-operates to create a more productive environment. The new language features, the compiler, the IDE, the intellisense, the documentation, all of them co-operate to give us a more smooth and painless development experience than VB6 does. It's not any one thing by itself.
I'm working on something in my spare time to add to this discussion which I hope will illustrate what I have been saying for years. I don't know if you have ever used VB6 Shaggy but I'm telling you, compared to VB.Net, it really is very painful to use. Think of a classic video game that has easy, medium and hard difficulty levels. VB.Net is like easy mode and VB6 feels like hard mode.
-
Nov 2nd, 2021, 09:30 PM
#791
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
...far more productive than VB6. This is the point...
If that was objectively true, then you should be able to "produce something" (in a week or two),
which would cause VB6-devs "strenuous labor for months, if not years" to replicate.
You had years already, to "wow everyone in the VB6 camp"... so,
where is the result of that "huuuge productivity-advantage"?
Occam's razor (and all the code-snippets we've seen so far) tells me, that it's non-existent.
Olaf
-
Nov 2nd, 2021, 09:51 PM
#792
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Schmidt
If that was objectively true, then you should be able to "produce something" (in a week or two),
which would cause VB6-devs "strenuous labor for months, if not years" to replicate.
It may not be that extreme, or it possibly could be. Either way I was thinking of smaller time scales.
An example that comes to mind from an actual real world scenario was when I was asked to implement multi-monitor support in our main VB6 application. I spent about 1 hour writing a couple functions to deal with it. The bulk of my time was spent learning how to use and writing out the Win32 declarations and helper functions to produce an easy-to-use VB6 friendly version of EnumDisplayMonitors. Testing it to make sure I got it right also took a fair bit of time. I remember thinking how unnecessary this would have been if this was a VB.Net application. The .Net Framework already had classes for dealing with this. I could have done it like 3 minutes if it was in VB.Net.
This is just one example, but I have had a number of experiences like this over the years.
Last edited by Niya; Nov 2nd, 2021 at 09:55 PM.
-
Nov 2nd, 2021, 10:02 PM
#793
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
The bulk of my time was spent learning how to use and writing out the Win32 declarations and helper functions -
to produce an easy-to-use VB6 friendly version of EnumDisplayMonitors. T
VB6+RC6:
Code:
Dim D As cDisplay
For Each D In New_c.Displays
Debug.Print D.IsPrimary, D.DPI, D.Zoom, D.TwipsPerPixelX, D.TwipsPerPixelY, _
D.WorkLeft, D.WorkRight, D.WorkTop, D.WorkBottom, _
D.AbsoluteLeft, D.AbsoluteRight, D.AbsoluteTop, D.AbsoluteBottom
Next
Olaf
-
Nov 2nd, 2021, 10:07 PM
#794
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
lol....I wish Google had lead me to that. It would have saved me a lot of time and I could have gone to bed early that night.
-
Nov 3rd, 2021, 09:27 AM
#795
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Originally Posted by Niya
I'm working on something in my spare time to add to this discussion which I hope will illustrate what I have been saying for years. I don't know if you have ever used VB6 Shaggy but I'm telling you, compared to VB.Net, it really is very painful to use. Think of a classic video game that has easy, medium and hard difficulty levels. VB.Net is like easy mode and VB6 feels like hard mode.
Yes, I used it for several years. I still have a few programs in use that were written in VB6. I'm not sure that for what I was doing, it really mattered all that much, since all I was writing were fairly simple LOB applications.
My usual boring signature: Nothing
-
Nov 4th, 2021, 05:10 AM
#796
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
An abnormal site issue has arisen.
This thread has not been updated on its usual daily basis.
I have corrected that.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Nov 4th, 2021, 09:05 AM
#797
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
You're too late. The abnormal issue was yesterday afternoon.
My usual boring signature: Nothing
-
Nov 6th, 2021, 09:25 AM
#798
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
More abnormality detected due to another day lacking abnormal activity.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Nov 6th, 2021, 12:46 PM
#799
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
I'm working on something to end this debate once and for all. But I do have actual work to do. I can't spend all day just debating in online forums so it will take a while.
-
Nov 6th, 2021, 01:03 PM
#800
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Yeah, right. Once and for all. More like reignite it.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|