4 ms·
All of what you mention is doable in VB.net. VB.net introduces a few rough edges, everything is class based, you have namespaces, lambdas, etc. But honestly th
by cm2187 10y ago
All of what you mention is doable in VB.net.
VB.net introduces a few rough edges, everything is class based, you have namespaces, lambdas, etc. But honestly the step from VB6 to VB.net is a pretty modest step, and when you have tasted generics, linq and its collection extensions functions (OrderBy, First, Last, Max, etc), a consistent collection indexing (VB6 switches between 0 based and 1 based), got rid of that useless "set" keyword, made all function parameters byval by default, which avoids having to write byval before every parameter, used lambdas (there are quite many problems where it is just nice to give a callback as a parameter), type inference, initializing a variable on the same line it is declared, multi-threading, etc, you won't go back to VB6.
I fully accept the non backward compatibility of the code argument. If it's a big project, and it's working, and it's in VB6, I can understand not upgrading it. But in term of functionality VB6 is way behind modern VB.Net.
- criddell 10y agoIt's been a while since I've dealt with them, but I know we had a bunch of DLLs written with VB6 that we could use the standard way: LoadLibrary load the DLL, then GetProcAddress to find the function, then call it. We converted some of these to VB.Net and then had to jump through a bunch of hoops (reg-free COM) to use it in that way.
- cm2187 10y agoI guess it depends what you want to consume your DLL from. A .net DLL can be consumed by a .net application without any form of registration, and I would assume this would be the typical use case. It's only if you want to expose your DLL with a COM interface to be used by other languages that you need a COM registration.
- deleted 10y ago[deleted]
- catnaroek 10y agoThe step from VB6 to VB.NET is far from “modest”. There are many fundamental differences between the two. For the most part VB.NET is a strict improvement over VB6, but there are a few things VB6 does better than VB.NET: (0) Reference counting: VB6 cleans up arbitrary resources (not just memory) in a deterministic fashion. Think RAII, minus the dangling references and associated gotchas. In business application programming, not worrying whether you closed database connections in the right places is a major productivity boost. (1) Programmer-defined lower and upper array bounds. You iterate an array's index range with `For idx = LBound(arr) To UBound(arr)`. It's as clear as it gets. (2) Dyamically resizable arrays. VB6's `ReDim` doesn't give you a new array object - it really changes the size of the existing one. By contrast, VB.NET's `ReDim` is just sugar for replacing a fixed-size array with another, which is why it can only be used locally inside a method. The officially sactioned solution is to use `List`s, but `List`s can't be multidimensional.
- cm2187 10y ago(0) In VB.net: Using Cn as new SqlConnection() End Using Will release the connection as soon as you get out of the using. Actually better than that, ADO.net will keep the connection alive for a few seconds such that if you make another connection to the same server, it reuses connections. I think VB.net still uses reference counting. But it does full garbage collections in addition to that. (1) The syntax has changed but does the same thing: For Idx = arr.GetLowerBound(0) To arr.GetUpperBound(0). (2) I don't think VB6's redim preserves the array. It resets it to its default values. You have to use "ReDim Preserve" instead, which has the same behavior in VB6 and VB.net. And I think I remember that either way you can only Redim the last dimension of the array. I think list feels more natural, I don't see a lot of value in writing explicitly the redim part of the code. I'd rather my code to focus on what I am trying to achieve, not some low level plumbing.
- catnaroek 10y ago(0) The problem with `Using` is that you can forget to use it. Or you can use it with the wrong object. It's no better than `free()` in C. On the other hand, you when you program in VB6, you can't forget to reference-count your objects, because the language implementation does it for you. (1) Noted. (2) I know the difference between `ReDim` and `ReDim Preserve`. And I'm not talking about the array's contents, I'm talking about the array's object identity. In VB6, both `ReDim` and `ReDim Preserve` preserve the array's identity in spite of the size change. .NET arrays don't support resizing at all, so VB.NET hides the limitation by only allowing `ReDim` on local array variables, and implementing it internally in terms of swapping array objects. And `List` stops being natural when you want it to be multidimensional.