Generalized Help Menu Database

  • 15 years ago

    Ok, now that my response post count is past 20  I figure I'll start asking my share of questions.  I am just starting to form an idea for a program at my work, so it has no true direction yet.  


    Issue:  We have 10 programmers that all work on their own jobs(mostly database programming for direct mailing).  Each programmer is a master at his regular jobs, but when they are sick or on vacation it takes a considerable amount of time for another programmer to figure out what to do to get a weekly job out.


    Solution:  I want to build a database of information where the users can pick a particular job and get a job description, howto, which programs to use, things to look for, etc.


    What I would really like to do is not have a simple list box to pick from but have a searchable/indexable help menu sort of like what you get when you open a normal program and hit help.  Example:  MSDN has a search/index type lookup for functions.  I'd like to do the same with job names, as well as put them into classes(inkjet, laser, inserting, etc.)  It doesn't have to be as advanced as the MSDN libraries and I do want to stick to VB code to make a portable EXE.  I would post an image, but it seems this site only allows links to pictures and so I can't directly upload anything.


    At this point I'm just looking for suggestions before I begin(still have to finiish one more project before I can start this).  I want it to look nice, so the other programmers will use it - and need it to be flexible(like read a config file) so I can add new jobs to it on the fly.  Anyway - through me your ideas, and I'll try and get a better grasp at want I want to do.


    Thanks.

  • 15 years ago

    I actually had a slow day today at work and got a basic working model of what I wanted.  I figured I'd post the code in case anyone else had a similar need.  It's nothing special, just we are growing at about 45% per year, so the need for centralized info has become essential.


    Code:


    Option Explicit


    Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
    Private Declare Function WaitForSingleObject Lib "kernel32.dll" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Const SYNCHRONIZE = &H100000
    Private Const INFINITE = &HFFFFFFFF


    Private Type HelpDatabase
       Programmer As String
       Company As String
       ProgramName As String
       ProgramLocation As String
       HelpFile As String
       Delete As Boolean
    End Type


    Dim MasterArray(1 To 1000) As HelpDatabase ' I will most likely make this dynamic in and redim in future updates
    Dim Index As Integer
    Dim BadRead As Boolean


    Private Sub ClearBoxes_Click()
       Call Clear
    End Sub


    Private Sub cmdExit_Click()
       Call WriteFile
       Unload frmMain
       End
    End Sub


    Private Sub cmdViewHelpClick()
       Me.Visible = False
       ProcessHandle Shell(("F:\U
    Edit\UEDIT32.EXE " & Trim(txtHelpFileLocation.Text)), vbNormalFocus)
       Me.Visible = True
    End Sub


    Private Sub FormLoad()
       Dim BadReadCount As Integer
       
       BadRead = False
       BadReadCount = 0
       JobSelect.Enabled = True
       
       Call ReadFile
       While BadRead = True And BadReadCount < 10
           DoEvents
           Sleep 5000
           Call ReadFile
           BadReadCount = BadReadCount + 1
       Wend
       If BadReadCount > 9 Then
           MsgBox ("Input database file has been locked for over 1 minute." & vbCrLf & "Please verify that F:\BRIAN\Help
    File_Database\Database.txt is not locked" & vbCrLf & "Program is exiting now...")
           Unload frmMain
           End
       End If
       
       frmMain.Height = "11475"
       frmMain.Width = "9915"
       cmdViewHelp.Enabled = False
       cmdDeleteRecord.Enabled = False
       cmdViewHelp.Enabled = False
    End Sub


    Private Sub ReadFile()
       Index = 0
       
       If Dir("F:\BRIAN\HelpFileDatabase\Database.txt") <> "" Then
           
           If FileLocked("F:\BRIAN\HelpFileDatabase\Database.txt") Then
               BadRead = True
               Exit Sub
           End If
           Open "F:\BRIAN\HelpFileDatabase\Database.txt" For Input As #1
               While Not EOF(1)
                   Index = Index + 1
                   Input #1, MasterArray(Index).Programmer, MasterArray(Index).Company, MasterArray(Index).ProgramName, MasterArray(Index).HelpFile, MasterArray(Index).ProgramLocation
                   JobSelect.AddItem MasterArray(Index).Company & " - " & MasterArray(Index).ProgramName
                   JobSelect.ItemData(JobSelect.NewIndex) = Index
               Wend
           Close #1
    End If
           
    End Sub


    Private Sub WriteFile()
       Dim i As Integer


       Open "F:\BRIAN\HelpFileDatabase\Database.txt" For Output As #2
           For i = 1 To Index
               If MasterArray(i).Delete = False Then
                   Write #2, MasterArray(i).Programmer, MasterArray(i).Company, MasterArray(i).ProgramName, MasterArray(i).HelpFile, MasterArray(i).ProgramLocation
               End If
           Next i
       Close #2
    End Sub


    Private Sub ProcessHandle(ProcessID As String)
           Dim Process
    Handle
           On Error GoTo 0
           ProcessHandle = OpenProcess(SYNCHRONIZE, 0, ProcessID)
           If ProcessHandle <> 0 Then
               Call WaitForSingleObject(Process
    Handle, INFINITE)
               Call CloseHandle(Process_Handle)
           End If
    End Sub


    Function FileLocked(FileName As String) As Boolean
       On Error Resume Next
       Open FileName For Binary Access Read Write Lock Read Write As #1
       Close #1
       If Err.Number <> 0 Then
           MsgBox ("Error #" & Str(Err.Number) & " - " & Err.Description & " when trying to open " & FileName & "!" & vbCrLf & "Please wait a moment and try again.")
           FileLocked = True
           Err.Clear
       End If
    End Function


    Private Sub Form_Unload(Cancel As Integer)
       Call WriteFile
       Unload frmMain
       End
    End Sub


    Private Sub JobSelect_Click()
       If JobSelect.ListIndex <> -1 Then
           cmdDeleteRecord.Enabled = True
           cmdViewHelp.Enabled = True
           txtProgrammer.Text = MasterArray(JobSelect.ItemData(JobSelect.ListIndex)).Programmer
           txtCompany.Text = MasterArray(JobSelect.ItemData(JobSelect.ListIndex)).Company
           txtProgramName.Text = MasterArray(JobSelect.ItemData(JobSelect.ListIndex)).ProgramName
           txtHelpFileLocation.Text = MasterArray(JobSelect.ItemData(JobSelect.ListIndex)).HelpFile
           txtProgramLocation.Text = MasterArray(JobSelect.ItemData(JobSelect.ListIndex)).ProgramLocation
       End If


    End Sub


    Private Sub cmdAddRecord_Click()


       If Trim(txtProgramName.Text) <> "" Then
           JobSelect.AddItem txtCompany.Text & " - " & txtProgramName.Text
           
           Index = Index + 1
           MasterArray(Index).Programmer = txtProgrammer.Text
           MasterArray(Index).Company = txtCompany.Text
           MasterArray(Index).ProgramName = txtProgramName.Text
           MasterArray(Index).HelpFile = txtHelpFileLocation.Text
           MasterArray(Index).ProgramLocation = txtProgramLocation.Text
           MasterArray(Index).Delete = False
           
           JobSelect.ItemData(JobSelect.NewIndex) = Index
           Call Clear
       End If


    End Sub


    Private Sub Clear()
       txtProgrammer.Text = ""
       txtCompany.Text = ""
       txtProgramName.Text = ""
       txtHelpFileLocation.Text = ""
       txtProgramLocation.Text = ""
    End Sub



    Private Sub cmdDeleteRecord_Click()


       If JobSelect.ListIndex <> -1 Then
           MasterArray(JobSelect.ItemData(JobSelect.ListIndex)).Delete = True
           JobSelect.RemoveItem JobSelect.ListIndex
           Call Clear
           Index = Index - 1
       End If
       
       If JobSelect.ListIndex = -1 Then
           cmdDeleteRecord.Enabled = False
           cmdViewHelp.Enabled = False
       End If
    End Sub

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“My definition of an expert in any field is a person who knows enough about what's really going on to be scared.” - P. J. Plauger