AvBrand Exploring Technology
AvBrand Exploring Technology
Blog 

Visual Basic 6? Why?

5:08 PM, July 16th, 2010

I occasionally get flak for the fact that my applications are mostly written in Visual Basic 6, a programming language that came out in 1998 and has since been replaced by Visual Basic.NET.

But I still use it to this day, and I have some good reasons why:

  • It performs well. It's not as fast as a native C++ application, but it's probably about as fast as a C# application.
  • I can create programs in it in the blink of an eye. I've been using it for so long and I know my way around it very well, and I can bang out a program in no time at all, with a full GUI.
  • It's fully Active-X COM compliant. There are a million components and add-ons and plugins that are Active-X controls and interfaces, so that means it's real easy to use one of those.
  • It can create Active-X COM DLLs too. These are usable in other languages including .NET.
  • It doesn't require a massive runtime that is difficult to understand and easy to mix up, like .NET does. Sure, it still needs some DLLs, but they usually come with Windows or are rather small.
  • It works fine on any version of Windows, including Windows 7 64-bit and Server, with no changes.
  • Without too much pain, you can use pretty much any Windows API function, including stuff like keyboard hooks.


Of course, it does have some limitations, which may be a dealbreaker for some people:

  • No 64-bit support. My apps run 32-bit, but of course they work fine on a 64-bit system.
  • No real multithreading. This isn't really a huge problem for me either, as threading is a headache and a half.
  • Fancy graphics and things like alpha transparencies and window subclassing aren't built in, like they are in .NET. So you need to go a bit further to get things like that working.


I do know C# and I use it every now and again, but I still find that VB6 provides the best time spent to results produced ratio for me.

Comments

Don 8:07 AM, July 17th, 2010

I couldn't agree more with your reasoning. I don't use VB6, I use an equally ancient version of Delphi, but my philosophy is the same. If it works and YOU like it, that's all that matters. Speed of development counts for a lot, and nothing like a tried and true platform lends to the speed of development. I really enjoy reading about the applications you've developed and they have inspired me to create similar ones for my own home automation and lifestyle uses. Thank you for sharing your great ideas.

Don

Henrik 7:53 AM, July 31st, 2010

I don't use VB or anything ancient. In fact I'm allways keeping up with the newest .NET technologies.

BUT I think it's really cool you use an old programming langauge and make real good systems out of it! Because, it's like everyone is "hey you use something different you are a looser!" these days. I'm programming in VB.NET and get flamed a lot for it. "It's to easy, it's a beginner langauge" .... Well, it can perfom the same things as C# and the speed is not really different at excution . It does however give me lot of power to do whatever I want and fast. I know C# to, and I've programmed in lot's of other langauges to try them out. But nothing matches VB.NET if you ask me. This is 100% personal, and I don't really care what other people use, and they shouldn't care about what I use.

Getting the job done is the most important thing, and if you work good in VB and I work good in VB.NET and maybe some guy like the other who have posted work good in an old version af Delphi so LET IT BE like that!

Just my five cents

Crypton 7:43 PM, January 29th, 2012

It doesn't require a massive runtime that is difficult to understand and easy to mix up, like .NET does.


Really? Have you looked into the namespaces of .NET? It's far more well designed than VB6 and there is quite a ton of stuff that comes out of box.

Also, in this day and age, most of the newer OSes from MS come with .net preinstalled, not to mention so many applications that automatically install it if you don't have it.

Without too much pain, you can use pretty much any Windows API function, including stuff like keyboard hooks.


Not very difficult, but then again, why would you use so much of Winapi, when there's XAML?


[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);




VB6 dev environment just does not compete with Visual Studio 2010

Crypton 7:52 PM, January 29th, 2012

An example!

Here is a LINQ query to select Forum Sections grouped into Groups. Each section may have permissions for different user groups. Here, we are only selecting sections that have 'View threads' enabled for group 'general'.


var items = from g in db.forum_SectionGroups
let allowedSections = g.Sections.Where(s => s.Permissions.Any(p => p.PermissionSetKey == "thread.view" && groupKeys.Contains(p.GroupKey) && p.Allow))
where allowedSections.Count() > 0
orderby g.Sequence ascending
select new {
Group = g,
AllowedSections = allowedSections
};

And the resulting SQL query


SELECT
[Project6].[Sequence] AS [Sequence],
[Project6].[Id] AS [Id],
[Project6].[Title] AS [Title],
[Project6].[Summary] AS [Summary],
[Project6].[IsActive] AS [IsActive],
[Project6].[C1] AS [C1],
[Project6].[Id1] AS [Id1],
[Project6].[Title1] AS [Title1],
[Project6].[Summary1] AS [Summary1],
[Project6].[SectionGroupId] AS [SectionGroupId],
[Project6].[Sequence1] AS [Sequence1]
FROM ( SELECT
[Filter4].[Id] AS [Id],
[Filter4].[Title] AS [Title],
[Filter4].[Summary] AS [Summary],
[Filter4].[Sequence] AS [Sequence],
[Filter4].[IsActive] AS [IsActive],
[Filter7].[Id] AS [Id1],
[Filter7].[Title] AS [Title1],
[Filter7].[Summary] AS [Summary1],
[Filter7].[SectionGroupId] AS [SectionGroupId],
[Filter7].[Sequence] AS [Sequence1],
CASE WHEN ([Filter7].[Id] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1]
FROM (SELECT [Project3].[Id] AS [Id], [Project3].[Title] AS [Title], [Project3].[Summary] AS [Summary], [Project3].[Sequence] AS [Sequence], [Project3].[IsActive] AS [IsActive]
FROM ( SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Title] AS [Title],
[Extent1].[Summary] AS [Summary],
[Extent1].[Sequence] AS [Sequence],
[Extent1].[IsActive] AS [IsActive],
(SELECT
COUNT(1) AS [A1]
FROM ( SELECT
[Extent2].[Id] AS [Id]
FROM [dbo].[forum_Section] AS [Extent2]
WHERE [Extent1].[Id] = [Extent2].[SectionGroupId]
) AS [Project1]
WHERE EXISTS (SELECT
1 AS [C1]
FROM [dbo].[forum_SectionPermission] AS [Extent3]
WHERE ([Project1].[Id] = [Extent3].[SectionId]) AND (N'thread.view' = [Extent3].[PermissionSetKey]) AND (N'general' = [Extent3].[GroupKey]) AND ([Extent3].[Allow] = 1)
)) AS [C1]
FROM [dbo].[forum_SectionGroup] AS [Extent1]
) AS [Project3]
WHERE [Project3].[C1] > 0 ) AS [Filter4]
OUTER APPLY (SELECT [Project4].[Id] AS [Id], [Project4].[Title] AS [Title], [Project4].[Summary] AS [Summary], [Project4].[SectionGroupId] AS [SectionGroupId], [Project4].[Sequence] AS [Sequence]
FROM ( SELECT
[Extent4].[Id] AS [Id],
[Extent4].[Title] AS [Title],
[Extent4].[Summary] AS [Summary],
[Extent4].[SectionGroupId] AS [SectionGroupId],
[Extent4].[Sequence] AS [Sequence]
FROM [dbo].[forum_Section] AS [Extent4]
WHERE [Filter4].[Id] = [Extent4].[SectionGroupId]
) AS [Project4]
WHERE EXISTS (SELECT
1 AS [C1]
FROM [dbo].[forum_SectionPermission] AS [Extent5]
WHERE ([Project4].[Id] = [Extent5].[SectionId]) AND (N'thread.view' = [Extent5].[PermissionSetKey]) AND (N'general' = [Extent5].[GroupKey]) AND ([Extent5].[Allow] = 1)
) ) AS [Filter7]
) AS [Project6]
ORDER BY [Project6].[Sequence] ASC, [Project6].[Id] ASC, [Project6].[C1] ASC
in ~17ms.

Pic: http://i.imgur.com/vzZyR.png

copyright © 2024 AvBrand.com - sitemap