Still maintaining ancient VB6 code, and wishing the mouse scroll wheel would work in the IDE? Microsoft has the solution, via a VB add-in. Q837910: Mouse wheel events do not work in the Visual Basic 6.0 IDE.
(Or for some reason if you reject the add-in, you can downgrade back to Intellipoint 4.12… doesn’t sound like a terrific idea to me.)
They do make you jump through some hoops, but I think I've got it worked out.
Dim dYourDateField As Nullable(Of Date)
…then you either set it to be a date (using DateSerial or CDate or whatever, or you set it to Nothing.
Then when you're using it in a database query, the parameter can be set like this:
rDateField”, System.Data.OleDb.OleDbType.DBDate).Value = dYourDateField
That's it. At least, it seems to work okay for me. Touch wood. Apparently it should be okay in the .Net Framework 2 onwards.
[Another in an occasional series of things Daniel posts about so he can easily re-discover it next time he needs to remember how it's done.]
A bunch of XML Tools from the good people at Got Dot Net. The particular one I needed was XSD Inference, which creates an XSD from an XML document. I needed it to use with some code to validate XML against XSDs in VB6. It seems XSDs created from XML with some tools (I’m looking at you, XMLSpy — though maybe it’s fixed in later versions) won’t work properly using VB6/XML Parser 4 (which is what I’m using, at least for some of my stuff).
Cool links I’ve found recently:
Super (MOV to AVI conversion).
VB to Java converter. That is, it compiles VB6 code into a Java class. Latest update here. Q+A. (No, you can’t download it yet, they’re still working on it.)
Oh, guess who’s on about giving away Digital set top boxes again? Yup. I do like this argument, actually: It is not the Government’s job to champion new technology. It is the Government’s job to provide universal infrastructure and manage the task in a financially responsible way.
XML Notepad, which after a looooong time not being available, is back, and upgraded. (Requires the .Net Framework 2).
I’m working on a project that uses web services code written in .Net (‘cos it’s heaps easier that way) but calls legacy code written in VB6. And vice versa.
(Wow, I never thought I’d be referring to VB6 code as legacy, but there you go. None of your smart comments, any VB-haters out there.)
Here’s what I’ve discovered about making it work. Continue reading
I’ve found under some circumstances, new versions of Windows (XP and 2000, using NTFS) are still looking at the DOS 8.3 versions of filenames when using wildcards.
Real world example: a set of files such as tpo12345.xml tpo12346.xml tpo12347.xml etc. To find these, you’d use a wildcard such as tpo?????.xml
If you have a file called tpo1234567890.xml, it shouldn’t match using this wildcard, but it does, because the filename’s backward-compatible short version (in DOS 8.3 format) is something like TPO123~1.XML, which matches. It appears to only happen when the first part of the wildcard (without the suffix) is 8 characters long.
So it may be ten years since most of us said goodbye to short filenames, but it seems they’re still with us. I wonder if Windows Vista will still use them?
Having got Visual Studio 2005 into my hot little hands, I’ve upgraded one of my projects from VS 2003 to 2005, and .Net Framework 1 to 2. Just loading it into VS2005 seemed to do most of the work for me.
I did find the new VS gives out a few very informative warnings in the code editor, such as unused variables. Good stuff (and shame on me for being so sloppy during repeated revisions of code).
The other thing I found was a few things had changed in the Web.Config file format. After much fiddling I found it easier to create a fresh one and copy my custom settings into it, than try and convert the old one over.
The only catch is that after copying it all over to the test server, it didn’t work. Turns out apart from installing the .Net 2.X Framework on your server, you’ll also need to get into the IIS setup and make sure it knows it’s now a 2.X application.
Other than that, pretty smooth. The one gotcha on my actual code was a custom button click routine that took the form QueryString and stripped out all the ASP.Net guff I didn’t want needed a bit of tweaking, as in .Net 2.0 there’s an extra __EVENTVALIDATION value. (My version is adapted from a 15seconds.com article, and is used to produce tidy QueryStrings that can be bookmarked.)
For die-hard BBC BASIC lovers, there’s a version for Windows which can be used to create fully-blown Windows applications, producing small standalone EXEs.
There are also implementations available for MS DOS, Mac and other platforms. (Though really, to do anything good, sounds like it’d be a hard slog. Personally I’ll probably stick to VB, despite the runtime libraries required.)
Well, I sorted out my problem of confusing warnings appearing whilst controlling Excel with VBA. Turns out there is an Application.DisplayAlerts property which, when set to false, hides warnings such as the one I was getting. It took a little Googling to find the solution, which wasn’t readily apparently in any of the MS help for the methods I’d got the warnings from.
The other Office applications also have a DisplayAlerts property.
Okay, this is annoying. I’m working on a VB program that uses the Excel object library to automate a fairly complex update into Excel. The general idea when you’re automating Excel is to smoothly do your operation behind-the-scenes, to hide the complexity from the user.
So the last thing you need is complicated dialog boxes popping up to ask the user questions. I’m the programmer: I’m meant to make the decisions. Tell me, the programmer, that if I save this Shared Workbook with a password that certain parts of the file won’t be encrypted. Don’t tell my user, and ask them to decide if it should happen or not.
To those who watch Microsoft’s dev tools, there are betas of the 2005 versions now available. MSDN subscribers can download full products straight away; others can order CDs, or stick to the Express products, which for trying out new languages, are quite nicely featured.
It’s a cunning strategy for Microsoft, helping to counter the proliferation of free programming languages such as Java and PHP by providing free development environments for ASP, VB, C#, C++ and their own (some would say mutated) J# implementation of Java.
MSDE, which has been around for years now, providing a royalty-free cut-down SQL Server, has been renamed SQL Server Express to show its heritage. (Well, its SQL Server heritage… most people know it grew out of Sybase, but that’s ancient history). Keeping it free thus helps fight off the MySql threat and allowing people for whom Access isn’t cutting it to be encouraged up to SQL Server).
Looking back 20 years to when I was growing up, trying out BASIC on my Commodore 64 or BBC Micro, I ponder how the next generation of programmers are getting hooked into this game. I suspect a mix of freebie entry-level products like this (and their counterparts from the world of open-source) is one way they can get involved. Which probably explains MS’s “Coding 4 Fun” web site.
Mainstream support for Visual Basic 6 (the last version before .Net) finished at the end of March, and there’s growing murmurs in the VB development community, calling for it to be resurrected. While “classic” VBers didn’t mind being shunted into the .Net framework, they objected to some of the bigger changes to the language itself, which made it difficult to migrate old projects over. And remembering that “classic” VB is the most popular computer language ever, there’s a lot of old systems out there still running with it. A petition has been organised, with nearly 200 MVPs having signed up so far.
Microsoft have put up a new site highlighting VB6 called VBRun (harking back to the pre version 5 days when the main DLL was called VBRun). It’ll have VB6 content on it, as well as nudging developers towards .Net.
I work with VB. I’ve got a lot of VB6 code still running. But I’m slowly moving some stuff over to .Net. I’m not convinced it’s better yet. It’s certainly different, but I’ll get used to it eventually.