You are here:About>Computing & Technology>Visual Basic
About.comVisual Basic
From Dan Mabbutt,
Your Guide to Visual Basic.
FREE Newsletter. Sign Up Now!

Microsoft: Are you trying to make VSTO fail?

The About Visual Basic Newsletter headlines a complete rewrite of a favorite series of articles this week:

Learn VBA Macro Coding with Word 2007 - A "From the Ground Up" Tutorial

This tutorial was originally published for Word 2000, so it's about time I brought it up to date.

When I decided to update the series, one of the things I did was check up on VSTO again. VSTO, if you don't recognize the acronym, is Visual Studio Tools for Office.

VBA is the very last remnant of COM programming (that is, VB6 level technology) in Microsoft's entire development suite of tools. If you open up Word 2007 and fire up the Visual Basic editor, those of you who loved good old VB6 will feel the love again. VSTO is Microsoft's chosen strategy for finally getting rid of it and replacing it with a .NET based technology.

The problem is that this is probably the most screwed up marketing decision Microsoft has ever made. (I disagreed with the original decision to jettison VB6 mainly on ethical grounds. It was just wrong to pull the rug out from under (formerly?) loyal VB6'ers who have poured billions into VB6 development over the years. But on a strictly business basis, I could see why they did it.)

The main problem with VSTO is that it's priced and packaged to guarantee that there is really no market for it. Let's review what VSTO is. It's Visual Studio Tools for Office (emphasis mine). That means that many of the people who are most likely to be interested in it are the Office mavens. The Word Wonders. The Spreadsheet Superheros. But to use VSTO, you need a copy of Visual Studio .NET 2008 Professional. You can't even buy the standard version. VSTO isn't in it. And you need to learn .NET programming.

In effect, you're telling the natural market for VSTO that in order to use it, they have to basically join the programming staff in the I/T department.

The people who will already be equipped to use VSTO, that is, the programming staff in the I/T department, are far more likely to simply say, "Why not just code up this sucker in regular VB.NET? We can use any of the Office libraries we need anyway. Why complicate things with VSTO?"

At this point, I'm going to recommend an old book review I did a few years ago ("Stupid! Stupid! Stupid!" - It really is a great book.) about how nearly all (that is, everybody but Microsoft) of the software companies from the great age of PC software shot themselves in the foot and disappeared from the face of the earth.

Don't tell me that the MBA's at Microsoft are smarter than that and they know what they're doing.

Saturday May 10, 2008 | permalink | comments (2)

Intellisense and Friend

Matías asked this question:

I have written a program library with a whole structure of classes. When I use the library in another project, all of the classes can be selected.

How can I code the library so that only one class shows up in Intellisense.

----------

Great question, Matías. That's what access modifiers are for. You mentioned that you tried one of them: "Private" but then the program wouldn't work. The one you want is "Friend." The documentation for "Friend" states:

In many cases, you want programming elements such as classes and structures to be used by the entire assembly, not only by the component that declares them. However, you might not want them to be accessible by code outside the assembly, for example if the application is proprietary. If you want to limit access to an element in this way, you can declare it with Friend.

That way, you get this result in Intellisense:

Wednesday May 7, 2008 | permalink | comments (0)

Interop

… and the state of technical conferences.

I invested a few days at Interop this week. Here's the bottom line:

It's a great investment!

That might tell you more about me than Interop. I've been geeky since wa-a-a-a-y before it was cool. But if you're geeky too, then Interop is probably the best of it's type that the US still has to offer.

You have to have a little history to understand that last statement.

In the beginning, there was NCC. And it was good.

AFIPS decided to start holding a national convention for their geeky members in 1973 to discuss advanced and visionary future technologies. For those who might not recognize the name, that's the American Federation of Information Processing Societies. The members of these organizations were the ubergeeks and were mostly in universities working on mainframes. Only really nutty types like Steve Jobs and Bill Gates were trying to make a business of personal computers.

But soon companies were crowding into NCC because it was the only real national event for computers. The problem was that geeks don't know how to run a show. They kept insisting it was just to learn about new technical ideas. They actually had a rule that no commerce could be done on the show floor. (Partly as a result, the show floor was ringed with little one-horse startups selling their wares on floppy disks. I met the inventor of the Zip file, Phil Katz, at his little stand where he was personally selling PKZip on a floppy.)

It didn't take long for someone (Actually, that someone was Sheldon Adelson, who stands alongside P. T. Barnum and Moses in the ability to really put on a show.) to notice that there was a real business opportunity here. And COMDEX, the Computer Dealers Exposition, was born.

NCC was good, but COMDEX was great! I tell you truly, as a young man, COMDEX was the most fun I had standing up.

I don't want to throw any rocks at Interop because, as I said, it's a good show and I had a great time, but comparing it to COMDEX in its prime would be like comparing a county carnival to Disneyworld. Just part of the space at one Las Vegas hotel is plenty for Interop. When COMDEX was flying high, they occupied the whole Las Vegas Convention Center, all of the space in about three other conventions centers, and big convention tents too. Las Vegas hotels celebrated by jacking their room rates into outer space. (Being young and poor, I drove in every morning from Mesquite, eighty miles away.) I remember looking out over the main show floor and the sea of vendor booths seemed to disappear into the horizon.

Some say COMDEX died simply because it got way too big, way too expensive, and business simply decided that they couldn't justify the expense anymore. That may be. But the world changed in other ways too.

Is programming still a great career choice?

Back when COMDEX was king, software stores sold Windows, Visual Basic, and Excel. Today, a software store sells Grand Theft Auto. Back then, the title "programmer" was right up there with "knight" or "secret agent" as a job title. Today it's ... well ... Something fundamental has changed in programming and I also invested my time at Interop interviewing people and asking a fundamental question designed to discover just what has changed. Here's what I learned.

Friday May 2, 2008 | permalink | comments (0)

Getting Fontsy

Peter ... a longtime VB 6 programmer who is now working his way into VB.NET ... wrote and asked:

-----------------

I'm pounding my head against VB.NET trying to get some VB6 programs to work.

My program contains the line...

openFileDialog1.InitialDirectory = "%fonts%"

In VB6 the "%fonts%" ended up being understood as the folder in which the system stored its fonts, without needing a hard-wired folder name.

How do I do this in VB.NET 2008?

-----------------

First, a little discussion of "%fonts%". This is called a DirID (Directory ID) in Windows programming. You can use the SetupSetDirectoryId Windows API to create user DirIDs.

DirID's are mainly used by .INF files. These are "information" files used when Windows installs device drivers and other programs. They are plain text files that you can view in Notepad. DirID's really map directly to numbers. System DirID's range from -1 through 32767. Peter is correct in that the fonts directory is assigned to the number 20.

But that doesn't mean that you can use it in programming. For example, if you open a Command Prompt window and type:

echo %windir%

The system will respond with:

C:\Windows

But my Vista Business SP1 system doesn't recognize the %fonts% DirID. The same test gives this result.

echo %fonts%
%fonts%

So ... even if it did work inside a VB program (VB6 or VB.NET), it's not a reliable way to do things. And, ummmmm ...., I sorta doubt that it can be made to work.

VB.NET has a better way to go. Actually, it has several better ways. Let's see what they are.

First, for convenient access, some commonly used directories can be accessed using the My.Computer object.

But, unfortunately, the fonts directory isn't one of them.

For fonts, you can use the the System.Drawing namespace to simply access the names of the fonts:

Dim ff As FontFamily For Each ff In _ System.Drawing.FontFamily.Families ListBox1.Items.Add(ff.Name) Next

It gets even easier than that, however. VB.NET also provides a custom dialog just for fonts: FontDialog. Just add one to your form and avoid any custom coding. To get started, this simple code assigns a user selected font to a TextBox:

If FontDialog1.ShowDialog() = DialogResult.OK Then TextBox1.Font = FontDialog1.Font End If

Sunday April 27, 2008 | permalink | comments (0)

Wotta Deal! Free Visual Studio 2008 Professional

It almost (but not quite) makes me want to be a student again!

Want a *free* copy of Visual Studio 2008 Professional? (The "Professional" Edition is a step up from the version that you get at the Launch Event. I drove 600 miles to Los Angeles mainly to get a free copy of 'standard' Visual Studio 2008!!)

There's just one catch: You have to be a student at one of the schools that is working with Microsoft on this deal. And it's an international program. According to the Microsoft FAQ:

We are initially launching in 11 countries, targeting millions of students in the United States, the United Kingdom, Canada, China, Germany, France, Finland, Spain, Sweden, Switzerland and Belgium. If your country isn’t listed, don’t worry, just stay tuned as we continue to add more locations. By 2009, we expect to have DreamSpark available to virtually ALL students around the world.

But your school MUST be working with Microsoft on this. You select your school from a list before they let you download and then be verified that you're a student. Oh man! Why didn't they have deals like this when I was a struggling student!!

Go to the DreamSpark page to get started:

https://downloads.channel8.msdn.com/Default.aspx

(Oh ... And they let you download other stuff too. Like Expression Studio, SQL Server 2005 Developer Edition, and Windows Server 2003.)

Thursday April 24, 2008 | permalink | comments (0)

Intellisense, Web Pages, and Scope

Things aren't are obvious as they once were ...

... and they never were very obvious.

Part 6 of the current tutorial, Learn ASP.NET 2.0 - Intro to the Grid Control, has been posted.

While writing this article, a new trend in Microsoft's development tools has started to really bug me. Consider the following code snippet:

The good news is that Microsoft's development tool is doing a great job of telling me that I have a problem. The bad news is that why I have a problem is getting more difficult than ever.

The rule used to be that if you didn't have a reference or Imports for a namespace in your program, an object wouldn't be found. But with partial classes and web pages, that rule doesn't apply anymore. Moving the TemplateField tag inside the Columns tag works.

I can't find anything in Microsoft's documentation that actually spells this out. I did find this:

"The TemplateField object is displayed differently depending on the data-bound control in which it is used. For example, the GridView control displays a TemplateField object as a column, and the DetailsView control displays it as a row."

Great! The same keyword does different things. Ya gotta love it!

I know ... this is HTML, not VB. But Intellisense still works. (In fact, that part of the tool seems to be getting better all the time.) You can still reference methods and properties of objects just like you can in VB code. And, in fact, this is a partial class but the code that makes it into one can't be seen.

Knowing what works where is getting more and more confusing so it's a good thing that Intellisense is getting better.

One of the big improvements in VB.NET 1.0 over VB 6 was that you could, for the first time, actually see the code that made your program work. Much of it was kept out of the way with the new Region directive, but you could check it out and even change it if you knew what you were doing. But the new tools are regressing back to the bad old habits of VB 6 again where the magic happens out of view. You just have to "know" where things go because if you don't code it that way, it doesn't work.

This is the "magic incantation" style. If you don't say the magic words just right, the spell doesn't work.

Wednesday April 23, 2008 | permalink | comments (0)

Murach's Visual Basic 2008

When you find a good thing ... Stick with it!

ISBN: 978-1-890774-45-5
List: $52.50
820 pages
Anne Boehm

If you haven't tried Mike Murach's style in software books, you're in for a real treat! They have a style and format unique in the publishing world.

  • The "paired page" format with the explanation on the left side and illustrations on the right ... on every page.
  • Content is written by employee authors, not hired guns. The author of this latest book is Anne Boehm, who now has a substantial record of Murach books.

Murach books are for learning. They're advertised as training and reference, but I think they're really training. Although they're used in a lot of paid instructional courses, the format and clear writing make them perfect for the do-it-yourself student of programming.

This latest offering for Visual Basic 2008 is much like the VB.NET 2008 itself: an incremental upgrade, not a total rewrite. A comparison with the same book for VB.NET 2005 shows that most of the content is relatively unchanged. The chapter on LINQ, like the technology, is completely new.

Since I'm very concerned with the problem of how to write so people will understand it, the fact that this book is an upgrade should only be taken as a positive. The second version of my work is usually a lot better than the first.

If you're in the market for a book that will do the best job possible of helping you learn VB.NET, you can't do better!

Tuesday April 15, 2008 | permalink | comments (0)

Parts 4 and 5 of the ASP.NET 2.0 Tutorial Posted

Learn ASP.NET 2.0

And there is a lot packed into these two segments of the tutorial:

  • ASP.NET 2.0 server controls
  • The tricks behind "code-behind"
  • Events in ASP.NET 2.0 program flow
  • Program tracing
  • Coding a SQL INSERT statement

Part 4 - ASP.NET 2.0 Server Controls

Part 5 - Code-Behind and Database Updating

Sunday April 13, 2008 | permalink | comments (0)

Send email from an ASP.NET web page

Part 3 of the Visual Web Developer Express Tutorial shows you how!

Part 3 of the Learn ASP.NET "from the ground up" tutorial focuses in on Visual Web Developer new features and differences. And the first version of web based system for sending email is programmed using VB.NET Web Developer.

Sending email is one of the most common requirements for a web page. It's not as difficult as you might think. Click here for Part 3.

Wednesday April 2, 2008 | permalink | comments (0)

Tooltips and Linklabels

A reader wrote to ask ...

"I use hundreds of web links in my Windows Forms application and I would love to have mouse over 'explanations' of the links."

We can do that!

If you have coded HTML, you might have used little Javascript programs triggered by onmouseover or onmouseout to do things. You can do the same thing with VB.NET using the Tooltip class.

Tooltips go back to VB6, but the way they work has changed completely in .NET. (What hasn't?) In VB6, controls have a ToolTipText property. At runtime, if the property isn't empty, the text is displayed.

In VB.NET, a Tooltip is an object like everything else in .NET. So you have to declare the object and then associate the Tooltip with the text and the control. It works like this:

Dim AVBToolTip As New ToolTip()
AVBToolTip.SetToolTip(control, "A GREAT Source for VB Info!")

The control that displays the Tooltip doesn't have a "tooltip" property like VB6. The text is assigned to the control using the SetToolTip method instead. Usually, this code will be placed where initialization is done such as the Load event for the form. One of the advantages is that now there are a lot of other properties and methods for the Tooltip such as:

AVBToolTip.AutoPopDelay = 3000
AVBToolTip.InitialDelay = 500
AVBToolTip.ReshowDelay = 500
AVBToolTip.ShowAlways = True

You can assign a Tooltip to the LinkLabel control to display links on a form. The LinkLabel is so flexible that I wrote a complete article on just that one component: The VB.NET LinkLabel.

Monday March 31, 2008 | permalink | comments (0)

Email to a Friend

Display Latest Headlines | | | Read Archives

powered by WordPress

Newsletters & RSSEmail to a friendSubmit to Digg
 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.