tutlogger

How to Add a Help File on VB.Net




In my previous post, I discussed a step by step tutorial on how to create a help file using the Microsoft HTML Help Workshop. ( Before you proceed reading this post, I urge you to read first  the article on how to create a help file by clicking here.). But if you already know how to make a help file, you may also want to know how to add a help file on VB.Net

Including a help file in a software program you develop will serve as a guide for the users to understand the features of your program and how do they work. In case a user do not know how and where to search records in your program, including a help file topic about how to search record may help the user.

In this tutorial, I will teach you how to add a help file in your Visual Basic project. Here's how to do it.

Step 1. Create your Help File project using the Microsoft HTML Help Workshop. Click here if you want to know how.


Step 2. After creating your Help File project, go to the root folder directory where your Help File project has been saved. Copy all the file inside by copying the root folder.




Step 3. Open your Visual Basic project folder and navigate to Project folder name > Bin >> Debug. Paste the Help File project folder inside Debug folder.




Step 4. Open your Visual Basic project. Create a new class.
(To add a class, right click to your project name on the Solution Explorer window > expand Add >> then click Class). 




Name the class as HTMLHelpClass and paste the code shown below inside this class after the Public Class HTMLHelpClass. 

   Private Shared HelpNamespaceValue As String
    Shared Property HelpNamespace() As String
        Get
            Return HelpNamespaceValue
        End Get
        Set(ByVal value As String)
            HelpNamespaceValue = value
        End Set
    End Property

    ' GetLocalHelpFileName() returns the full filename with path
    ' to the help file located in the same directory with the
    ' compiled EXE file
    Shared Function GetLocalHelpFileName(ByVal FileName As String) As String
        Dim ExeName, DirName, HelpFileName As String
        ExeName = Environment.GetCommandLineArgs(0)
        DirName = System.IO.Path.GetDirectoryName(ExeName)
        HelpFileName = DirName + "\" + FileName
        Return HelpFileName

    End Function

Step 5. Go to your main form, grab a menu strip from your project toolbox (if you can't find your toolbox just go to View > Toolbox) and add Help as a menu. Under Help menu > add User's Manual sub-menu. 




Step 6. Double click  User's Manual sub-menu or right click and view code, then paste this code:

Help.ShowHelp(Me, HTMLHelpClass.HelpNamespace, HelpNavigator.TableOfContents, "")

Ok. That's all, you now have a compiled chm Help File in your Visual Basic project.



SHARE THIS POST

No comments:

Post a Comment

PRIVACY POLICY | TERMS OF SERVICE | COPYRIGHT POLICY