Recently in VB.Net Category

CDOSYS.dll missing

| 1 Comment

As I worked to convert the c# info in my post about saving a web page as an mht file, I ran into a problem with the reference to cdosys.dll.

A little research brought me to this page:

318823 - CDO for Windows 2000 Library Reference Is Unavailable in Visual Basic Project

There I learned:

If you try to create or modify a project that references the Microsoft Collaboration Data Objects for Windows 2000 (CDOSYS) Library, the reference is not available. The reference for the Microsoft Collaboration Data Objects (CDO) for Exchange 2000 Library is present instead.

So the quest continues.

Saveas MTH file


I want to download and programatically save web pages as mht files. I was having a hard time until I went to IE SaveAS MHTML in C#, where I found the following code:

Make a reference to these two COM objects:
C:\Program Files\Common Files\System\ado\msado15.dll

I don't think neither of these have PIAs (Primary Interop Assembly) so this will generate two typelibs for your project.

The Source:

CDO.MessageClass message = new CDO.MessageClass();
message.CreateMHTMLBody("", CDO.CdoMHTMLFlags.cdoSuppressNone, "", "");

ADODB.Stream stream = message.GetStream();
stream.SaveToFile("fanms.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite);

Now I just have to change it to VB.

Update: Here is my version of this code in VB:

Dim message As New CDO.MessageClass()
message.CreateMHTMLBody("", CDO.CdoMHTMLFlags.cdoSuppressNone, "", "")

Dim Outstream As ADODB.Stream
Outstream = message.GetStream
Outstream.SaveToFile("c:\test.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)

Very Useful Moveable Type Plug-in

I used the plugin that I found at Movable Type Plugins: Supplemental Calendar Tags plugin documentation to add a 3 month calendar to my index page.

TreeNode Level

If you spend any time working with Treeviews, I can't imagine not needing this or having to invent it yourself:

Windows Forms FAQ - Windows Forms TreeView


Public Sub NodateLevel(ByVal node as TreeNode) As Integer

Dim level as Integer = 0

While Not node Is Nothing

node = node.Parent

level = level 1

End While

End Sub

I edited into this:

Private Function NodeLevel(ByVal node As TreeNode) As Integer
Dim level As Integer = 0
While Not node Is Nothing
node = node.Parent
level = level + 1
End While
End Function

Hide Datagrid Expanders

| 1 Comment

In the program I am developing, I wanted to show data from a table in a datagrid. This table is related to another table. As a result, this datagrid would show an expander and the name of that other table. I wanted this hidden. So I asked myself, "How do I hide the expander?" I didn't know so I searched and found the following:

Microsoft Support WebCasts

One DataGrid is designated to be the master grid and the second is designated to be the details grid. When you select an entry in the master list, all of the related child entries are shown in the details list. As you can see, there are no expanders shown on the master DataGrid. This is done by setting the AllowNavigation property of the DataGrid controls to false.

So there you have it set AllowNavigation to False. If you happen to find this useful, please link to this post as there is nothing that says to do this to hide them. I think this would be very helpful to others.

Version Number

I used information from Versioning an Assembly to be able to control the version numbers of my current project.


imports system
imports system.reflection
Imports System.Runtime.InteropServices

<Assembly: AssemblyTitle("")>

<Assembly: AssemblyDescription("")>

<Assembly: AssemblyCompany("")>

<Assembly: AssemblyProduct("")>

<Assembly: AssemblyCopyright("")>

<Assembly: AssemblyTrademark("")>

<Assembly: CLSCompliant(True)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("41BD3203-06FC-4FF4-8A74-3C842C207D49")>

' Version information for an assembly consists of the following four values:
' Major Version
' Minor Version
' Build Number
' Revision
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:

<Assembly: AssemblyVersion("")>

Long List of How To's

I stumbled across this list. I think it may be very helpful in the future:
Microsoft QuickStart Tutorials

Bringing a specific window to the top yet again

I was still having problems so I found this page:
Create a Form that Cannot Be Activated

From It I found this that seems to work better:

Private Declare Function BringWindowToTop _
Lib "user32" (ByVal hwnd As Long) As Long

Manipulating Word and Its SpellChecker pt. 1

Now that I have the handle for Word I need to make use of the Topmost function to raise it above the others. I found this page to be helpful:

VB TopMost Function

The most useful parts are:

Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Public Sub MakeTopMost(Handle As Long)
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Public Sub MakeNormal(Handle As Long)
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Word's Classname

About this Archive

This page is an archive of recent entries in the VB.Net category.

Programming Projects is the previous category.

Windows XP is the next category.

Find recent content on the main index or look in the archives to find all content.