Jump to content

Use Form2 as option window for form1

- - - - -

  • Please log in to reply
5 replies to this topic

#1
neraniggy

neraniggy

    Newbie

  • Members
  • Pip
  • 7 posts
In form1 I have a timer and a progressbar, for example -
when that progressbar hit 10 it will close a process.
When it hit 20 it will open that process.
When it hit 30 it will close that process, again.
Heres a code so hopefully you understand what i mean:
 If ProgressBar1.Value = "10" Then

            Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("chrome")


            For Each p As Process In pProcess

                p.Kill()

            Next

        End If

        If ProgressBar1.Value = "20" Then

            System.Diagnostics.Process.Start(URLbox.Text) '2

            LabelX.Text = "2"

        End If

        If ProgressBar1.Value = "30" Then

            Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("chrome")


            For Each p As Process In pProcess

                p.Kill()

            Next

        End If

Now to the problem im having, I also have form2.
In form2 i have 2 checkboxes one "Chrome" and one "Firefox"
When for example "firefox" is checked i want it to close the process "Firefox" in form1
Instead of "Chrome" wich is deafult.
I have no clue how to do this tou, hopefully i can get some help.
Thanks

#2
naugthall

naugthall

    Newbie

  • Members
  • Pip
  • 6 posts
There are many ways to do that.
For example, you can make two procedures in form1 one of them for kill "firefox" process and other for the "crome" one.

When you chek firefox in form2 you can call the process that kill this process in the first form....

I hope you can understand me, my english it's not very good

#3
neraniggy

neraniggy

    Newbie

  • Members
  • Pip
  • 7 posts

naugthall said:

There are many ways to do that.
For example, you can make two procedures in form1 one of them for kill "firefox" process and other for the "crome" one.

When you chek firefox in form2 you can call the process that kill this process in the first form....

I hope you can understand me, my english it's not very good
Thanks for you answer.
Im fairly new to coding,can you explain for me how you do that? or if you have a link of a tutorial.
Thanks again.

#4
yakisoba

yakisoba

    Newbie

  • Members
  • Pip
  • 1 posts
If you want to check them from a process running in Form1, just access the Form2 checkboxes using the full formname like so:

If Form2.chkFirefox.Value = 1 Then

      KillThisProcess("firefox")

ElseIf Form2.chkChrome.Value = 1 Then

      KillThisProcess("chrome")

End If


On the other hand, if you want to call procedures in Form1 from Form2, like if you click a checkbox on Form2 and want to fire something in Form1, make a Public Sub in Form1:

Public Sub KillThisProcess(sProcessName as String)

     KillProcess(sProcessName)

End Sub


And in a procedure in Form2, just call:

Private Sub chkFirefox_Click()

     Form1.KillThisProcess("firefox")

End Sub


The difference between Public and Private scope is whether other modules and forms can call it's procedures (Subs and Functions.)

Edited by yakisoba, 22 February 2011 - 08:57 AM.
trying code tags


#5
neraniggy

neraniggy

    Newbie

  • Members
  • Pip
  • 7 posts

yakisoba said:

If you want to check them from a process running in Form1, just access the Form2 checkboxes using the full formname like so:

If Form2.chkFirefox.Value = 1 Then

      KillThisProcess("firefox")

ElseIf Form2.chkChrome.Value = 1 Then

      KillThisProcess("chrome")

End If


On the other hand, if you want to call procedures in Form1 from Form2, like if you click a checkbox on Form2 and want to fire something in Form1, make a Public Sub in Form1:

Public Sub KillThisProcess(sProcessName as String)

     KillProcess(sProcessName)

End Sub


And in a procedure in Form2, just call:

Private Sub chkFirefox_Click()

     Form1.KillThisProcess("firefox")

End Sub


The difference between Public and Private scope is whether other modules and forms can call it's procedures (Subs and Functions.)

how would i put this in my code?
and thank you very much for your answer.

#6
naugthall

naugthall

    Newbie

  • Members
  • Pip
  • 6 posts
Thanks yakisoba for ask, i'm realy busy this week.
The code has writed yakisoba looks fine.

Yakisoba puts two options in the first one put the procedure of the top in the form1 and call 'chkFirefox' at the checkbox in the form2; the other option its like yakisoba explain taking care with the name of the checkbox




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users