9 Replies - 474 Views - Last Post: 23 January 2013 - 09:58 AM Rate Topic: -----

#1 saint1000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

when debuging, when program finish window closes how can i stop this

Posted 22 January 2013 - 10:27 PM

i am new to vb and on quite the learning cure. i am workng on a program with random number generators, multiple timerers, and usb rlay and i/o. everything was going fine untill i got to a point where i needed a random number generator to create a number, wait for a timer to expire, then creat another number. it needed to do this untill a master timer expired. i finally got this to work the way i wanted, but now when the master timer expires, it closes all the forms. it didnt do this be for. here his the script i added. i didnt change anything on any of the timers. i need for the form 1 to stay open.
 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Enabled = True
        Button2.Enabled = False
        If Form2.RadioButton5.Checked = True Then random()

    End Sub

    Private Sub random()

        Do
            Form2.Timer1.Enabled = True
            Label3.Text = Label3.Text + 1

            Dim rndnumber As Random
            Dim number As Integer
            rndnumber = New Random
            number = rndnumber.Next(1, 4)
            Form2.Label2.Text = number.ToString

            Do Until Form2.Timer1.Enabled = False
                If Timer1.Enabled = False Then End
                Application.DoEvents()
            Loop
        Loop

    End Sub


This post has been edited by macosxnerd101: 22 January 2013 - 11:05 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: when debuging, when program finish window closes how can i stop this

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,661
  • Joined: 02-June 10

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 07:33 AM

Your assignment is to do this in VB6? You're deliberately going to school to learn a language that's been dead for a decade? Should this be moved to VB.NET?

Please read: This is not the VB.NET forum
Please read: Is learning VB6 now a complete waste of time?


I'm not a VB guy, so tell me what the 'end' command does in Visual Basic.

21 If Timer1.Enabled = False Then End

This post has been edited by tlhIn`toq: 23 January 2013 - 07:36 AM

Was This Post Helpful? 0
  • +
  • -

#3 saint1000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 08:21 AM

sorry. like i said im new. should be in vb.net
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,661
  • Joined: 02-June 10

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 08:33 AM

But other than that, do you see why your program is ending now?

View PosttlhIn`toq, on 23 January 2013 - 08:33 AM, said:

21 If Timer1.Enabled = False Then End

Was This Post Helpful? 0
  • +
  • -

#5 saint1000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 08:54 AM

yes, but what other command can i use to terminate the process with out closing the whole program. thanks for your help.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8940
  • View blog
  • Posts: 33,527
  • Joined: 12-June 08

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 08:59 AM

The process aka the thread aka the app, if ended, *is* supposed to close down. What exactly are you trying to get out of? The do-while loop? Try 'exit'. Outside of that you need to take a serious look at how that whole chunk of code is structured and find a better way than throwing a cover all like 'Application.DoEvents()' in there.
Was This Post Helpful? 0
  • +
  • -

#7 saint1000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 09:08 AM

i just want the program to stop and be able to restart when i hit the start button again. leave the program open. thanks again
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8940
  • View blog
  • Posts: 33,527
  • Joined: 12-June 08

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 09:12 AM

You are asking something that doesn't fundamentally make sense. Stopping the app is killing the process, right? You can.. I don't know.. stop the work flow or state of your app.. but to stop the actual app thread/process *IS* closing it.
Was This Post Helpful? 1
  • +
  • -

#9 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,661
  • Joined: 02-June 10

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 09:17 AM

View Postsaint1000, on 23 January 2013 - 10:08 AM, said:

i just want the program to stop and be able to restart when i hit the start button again. leave the program open. thanks again


This sounds very much like you've built a sequence that you want to start over, instead of a program that could just keep working. In other words bad design. Plan before banging on the keyboard.

If you have a sequence you need to walk the user through, the code it like that..


void StartUserSequence()
{
   'run sub One
   'sun sub two
   'run sub three
   'run sub four
   ' As user if they want to go again
   ' if yes, then run StartUserSequence()
}

Was This Post Helpful? 0
  • +
  • -

#10 saint1000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Re: when debuging, when program finish window closes how can i stop this

Posted 23 January 2013 - 09:58 AM

thanks for your replies. i am not in school learning code. just reading and doing it on my own. im sure ill make many mistakes. thank you all for your input. you have helped me alot! its all part of the learning process for me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1