please, explain dis codes, ASAP - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

please, explain dis codes, ASAP

SquaLeonSquaLeon Posts: 4Member
NOTE: this is the program named voice recognition that I have downloaded, can somebody tell me and explain to me what are the meaning of the codes used in the form_load(). Because I dont know what are they. Also the declarations used in the options explicit and directsr1.phrasefinish(). Please elaborate to me the codes per line it will be a great help for us because we will have our thesis defense this coming Sunday


VB LAUNCHER

FORM 1 CODE:

Dim EngineEnable As Boolean



Private Sub cmdAdd_Click()
Dim I As Long
Dim Updated As Boolean
'check to see if TEXT item already exists...

If Trim(txtName) = "" Then
Exit Sub
End If

For I = 0 To lstNames.ListCount - 1
If LCase(lstNames.List(I)) = LCase(txtName) Then
'modify...
lstNames.List(I) = txtName
lstPaths.List(I) = txtPath
Updated = True
End If
Next I

If Not Updated Then
'create new
lstNames.AddItem txtName
lstPaths.AddItem txtPath
End If

txtName = "": txtPath = ""
SaveALL
InitEngine
End Sub

Private Sub cmdBrowse_Click()
On Error Resume Next

dlg.ShowOpen

If Err.Number <> 0 Then
Err.Clear
Exit Sub
End If

txtPath = dlg.FileName
End Sub

Private Sub cmdDel_Click()
If lstNames.ListIndex <> -1 Then
txtName = "": txtPath = ""
lstPaths.RemoveItem lstNames.ListIndex
lstNames.RemoveItem lstNames.ListIndex
End If

SaveALL
InitEngine
End Sub

Private Sub cmdStartup_Click()
Dim MBResults As VbMsgBoxResult
Dim AppExeName As String

MBResults = MsgBox("If you want, you can set CompCommand to auto-start when windows starts, allowing you to tell your commands whitout having to open manually the program! It requires very low ressources. Would you like to have CompRequest started at Windows startup?", vbQuestion + vbYesNo)

If MBResults = vbYes Then
AppExeName = App.Path & IIf(Right(App.Path, 1) = "", "", "") & App.EXEName
savestring HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionRun", "CompRequest", AppExeName
Else
DeleteValue HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionRun", "CompRequest"
End If
End Sub

Private Sub Form_Load()

Dim AppExeName As String
AppExeName = App.Path & IIf(Right(App.Path, 1) = "", "", "") & App.EXEName
savestring HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionRun", "CompRequest", AppExeName


If App.PrevInstance Then
MsgBox "There is already an instance of CompCommand running on your system! Just click on the MIC icon near the clock (in the system tray).", vbExclamation
End
End If

With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = Caption & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid

EngineEnable = True

LoadALL
InitEngine

On Error Resume Next
Open App.Path & "
ointro" For Input As #2
Close #2

If Err.Number = 53 Then
chkIntro.Value = vbChecked
Err.Clear
Else
chkIntro.Value = vbUnchecked
End If

'hide the APP
Hide
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
'This procedure receives the callbacks f
' rom the System Tray icon.
Dim Result As Long
Dim MSG As Long
'The value of X will vary depending upon
' the scalemode setting


If Me.ScaleMode = vbPixels Then
MSG = x
Else
MSG = x / Screen.TwipsPerPixelX
End If


Select Case MSG
Case WM_LBUTTONUP '514 restore form window
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
Case WM_LBUTTONDBLCLK '515 restore form window
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
Case WM_RBUTTONUP '517 display popup menu
Result = SetForegroundWindow(Me.hwnd)
'***** STOP! and make sure that your fir
' st menu item
' is named "mnu_1", otherwise you will g
' et an erro below!!! *******

If EngineEnable Then
mnuDisable.Visible = True
mnuEnable.Visible = False
Else
mnuDisable.Visible = False
mnuEnable.Visible = True
End If

Me.PopupMenu Me.mnu_1
End Select
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = 0 Then
If MsgBox("Instead of closing the program, it is recommended that you minimize it (it will send it to the systray). Would you like to close (and stop listening commands)?", vbQuestion + vbYesNo) = vbNo Then
Cancel = 1
End If
End If
End Sub

Private Sub Form_Resize()
If WindowState = vbMinimized Then
WindowState = vbNormal
Hide
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Shell_NotifyIcon NIM_DELETE, nid
End Sub

Private Sub lstNames_Click()
txtName = lstNames.List(lstNames.ListIndex)
txtPath = lstPaths.List(lstNames.ListIndex)
End Sub

Private Sub mnuDisable_Click()
EngineEnable = False
Speech.Deactivate
End Sub

Private Sub mnuEnable_Click()
EngineEnable = True
Speech.GrammarFromFile App.Path & " ext_cmd.ini"
Speech.Activate
End Sub

Private Sub mnuExit_Click()
Unload Me
End Sub

Sub SaveALL()
Dim I As Long

Open App.Path & "prgm_cmd.ini" For Output As #1
For I = 0 To lstNames.ListCount - 1
Write #1, lstNames.List(I), lstPaths.List(I)
Next I
Close #1

'for MICROSOFT compatibility...
Open App.Path & " ext_cmd.ini" For Output As #1
Print #1, "[Grammer]"
Print #1, ""
Print #1, "Type=Cfg"
Print #1, ""
Print #1, "[]"
For I = 0 To lstNames.ListCount - 1
Print #1, "=" & lstNames.List(I)
Next I
Close #1
End Sub

Sub LoadALL()
Dim I As Long
Dim strdata As String, strData2 As String

On Error Resume Next

Open App.Path & "prgm_cmd.ini" For Input As #1
If Err.Number <> 0 Then
MsgBox "Error while loading from config file -- aborting!", vbCritical
Err.Clear
Exit Sub
End If

Do Until EOF(1)
Input #1, strdata, strData2
lstNames.AddItem strdata
lstPaths.AddItem strData2
Loop
Close #1
End Sub

Sub InitEngine()
If EngineEnable Then
Speech.Deactivate
Speech.GrammarFromFile App.Path & " ext_cmd.ini"
Speech.Activate
End If
End Sub

Private Sub mnuShow_Click()
Dim Result

Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
End Sub

Private Sub Speech_PhraseFinish(ByVal flags As Long, ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, ByVal results As Long)
Dim I As Integer
Dim r

If Trim(Phrase) <> "" Then
lblCmd = Phrase
For I = 0 To lstNames.ListCount - 1
If Phrase = lstNames.List(I) Then
'attempt to SHELL the app...
r = ShellExecute(hwnd, "", lstPaths.List(I), "", "", 1)

If r <= 32 Then
MsgBox "There was an error while attempting to run the application associated with " & Phrase & "!", vbCritical
Err.Clear
Exit Sub
End If
End If
Next I
Else
lblCmd = "The last command you entered was not understood!"
End If
End Sub

Sign In or Register to comment.