Professional Documents
Culture Documents
display=Print
1 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
Introduction
Have you been looking for an API viewer for VB 9 and C# 3? Has the
old API viewers not been able to work in Vista® or Windows 7®?
VSAPIVIEWER is a remake of Pramod Kumar Singh's 2002 API
Viewer. Pramod's version, I believe, was written in VB.NET 7.0®.
Background
After I had downloaded Pramod's app and started to read his code, I
started to finally get hold of what he was trying to do.
FormSplash.Status("Loading Constants!")
LoadConstants()
FormSplash.Status("Loading Functions!")
LoadFunctions()
FormSplash.Status("Loading Subs!")
LoadSubs()
FormSplash.Status("Loading Types!")
LoadTypes()
End Sub
2 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
Try
ThreadConst.Join()
Catch e As Exception
MessageBox.Show("Error occured reading file..." &
vbCrLf & strFile1, _
"Error...", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
Thread.Sleep(250)
End Sub
3 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
input = sr.ReadLine()
After all the data that is found in the four API files is stored in the
app, and the app is finally displayed, we finally get to use it.
One important part of the application that was pointed out to me was
if someone accidentally pressed the Add button twice, duplicates
were added. Deleting these out manually is somewhat time
consuming, so I came up with this code:
4 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
The first thing that we do is check to see if the ListBox has any
items in it. If so, we continue. We then check the Combobox's text. It
doesn't matter if it is "Constants", "Declares", "Subs", or
"Types". It will check for any type of duplicate. If we find a
duplicate, then we display a MessageBox (shown below) to the user
telling that we have found a duplicate and that we are erasing it
from the TextBox. If no duplicates are found, then we add it to the
correct TextBox.
Classes
The CConst, CDeclare, CSubs, and CTypes classes have pretty
much the same properties and variables. Here is a list of the class
properties and variables. They all implement the IStore Interface.
Properties
5 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
Duplicate code
While going through the old API Viewer code, I noticed an awful lot
of duplicate code in all the radio buttons, combo, and listboxes. As I
did not understand why all this duplicate code was in there, a friend
told me to delete it all out and start from scratch. This was done and
the cmbAPI_SelectedIndexChanged (code below) was created
using the old code from two different places. The Select Case
statement is from the original combobox.click event, and the code
inside the Case statements is from the FileHandling.vb file.
6 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
txtSelectedItems.Text = ""
'Load the listbox from the selected arrayed strings.
Select Case cmbAPI.Text
Case RSP.CMB_CONSTANTS
lstItems.Items.Clear()
For i As Integer = 0 To RSP.Constants.Count - 1
Dim sKey As String
sKey = RSP.Constants.GetKey(i)
If sKey <> "" Then
lstItems.Items.Add(RSP.Constants.GetKey(i).ToString())
Next
Case RSP.CMB_DECLARES
lstItems.Items.Clear()
For i As Integer = 0 To RSP.Declares.Count - 1
Dim sKey As String
sKey = RSP.Declares.GetKey(i)
If sKey <> "" Then
lstItems.Items.Add(RSP.Declares.GetKey(i).ToString())
Next
Case RSP.CMB_TYPES
lstItems.Items.Clear()
For i As Integer = 0 To RSP.Types.Count - 1
Dim sKey As String
sKey = RSP.Types.GetKey(i)
If sKey <> "" Then
lstItems.Items.Add(RSP.Types.GetKey(i).ToString())
Next
Case RSP.CMB_SUBS
lstItems.Items.Clear()
For i As Integer = 0 To RSP.Torpedoes.Count - 1
Dim sKey As String
sKey = RSP.Torpedoes.GetKey(i)
If sKey <> "" Then
lstItems.Items.Add(RSP.Torpedoes.GetKey(i).ToString())
Next
Case Else
End Select
End Sub
That's all folks. Hope all of you can make use of this application.
7 of 8 12/15/2010 4:42 PM
VB 9.0, C# 3.0 API Viewer - CodeProject http://www.codeproject.com/KB/vb/VSAPIVIEWER.aspx?display=Print
History
Uploaded project on 07/09/2010.
Updated project and article on 07/18/2010.
License
This article, along with any associated source code and files, is
licensed under The Code Project Open License (CPOL)
United States
Member
8 of 8 12/15/2010 4:42 PM