I am trying to check for certain processes that is running and then inform the user of those processes via textbox like "The programs; -name of the processes running goes here- are running"

The I am using is

Dim iIndex As Integer
        Dim isd As Integer = 0

        iIndex = Dialog1.ListBox1.FindStringExact("msaccess")
        If iIndex <> -1 Then
            Dialog1.ListBox1.SelectedIndex = iIndex
            Dialog1.ListBox1.TopIndex = iIndex
            textbox.Text = textbox.Text & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "     -> MS Access"
        Else
            isd += 1
        End If

        iIndex = Dialog1.ListBox1.FindStringExact("excel")
        If iIndex <> -1 Then
            Dialog1.ListBox1.SelectedIndex = iIndex
            Dialog1.ListBox1.TopIndex = iIndex
            textbox.Text = textbox.Text & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "     -> MS Excel"
        Else
            isd += 1
        End If

        iIndex = Dialog1.ListBox1.FindStringExact("wmplayer")
        If iIndex <> -1 Then
            Dialog1.ListBox1.SelectedIndex = iIndex
            Dialog1.ListBox1.TopIndex = iIndex
            textbox.Text = textbox.Text & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "     -> Windows Media Player"
        Else
            isd += 1
        End If

        iIndex = Dialog1.ListBox1.FindStringExact("powerpoint")
        If iIndex <> -1 Then
            Dialog1.ListBox1.SelectedIndex = iIndex
            Dialog1.ListBox1.TopIndex = iIndex
            textbox.Text = textbox.Text & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "     -> MS Powerpoint"
        Else
            isd += 1
        End If

        iIndex = Dialog1.ListBox1.FindStringExact("winword")
        If iIndex <> -1 Then
            Dialog1.ListBox1.SelectedIndex = iIndex
            Dialog1.ListBox1.TopIndex = iIndex
            textbox.Text = textbox.Text & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "     -> MS Word"
        Else
            isd += 1
        End If

        If isd <> 0 Then
            textbox.Text = textbox.Text & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "     -> NONE :)"
        End If
Private Sub getallproc(ByVal lst As ListBox)
        Dim ProcessList As System.Diagnostics.Process()
        ProcessList = System.Diagnostics.Process.GetProcesses()
        Dim Proc As System.Diagnostics.Process
        For Each Proc In ProcessList
            lst.Items.Add(Proc.ProcessName.ToLower) ' & Proc.Id)
        Next
    End Sub

I know its a bit confusing but I have no idea i can do this in any other way if you guys know please let me know how it may be posible. My code does not work :(

You could use the method GetProcessesByName in order to determine if a certain process is running.
It returns an array of processes containing all instances of a certain named process, for example "wmplayer".
If the Length of the array is greater than 0, then that particular process is running.
This snippet also eliminates the need for ListBoxes and things like that.

If GetProcesses("wmplayer") > 0 Then
   textbox.Text = textbox.Text & Environment.NewLine & "     -> Windows Media Player"
End If

Private Function GetProcesses(nameOfProcess As String) As Integer
   Dim namedProcess As Process() = Process.GetProcessesByName(nameOfProcess)
   Return namedProcess.Length
End Function

thanks a lot Oxiegen :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.