Results 1 to 11 of 11

Thread: Restarting my VB6 Program

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2012
    Posts
    433

    Restarting my VB6 Program

    I want to make my VB6 program restart(terminate->start) programatically.
    Is it possible?

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Restarting my VB6 Program

    It is possible but what circumstance do you want the program to restart itself, on some application error? You would need a way to quit the program without calling the "Restart" code incase the user wants to quit the program without restarting.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Restarting my VB6 Program

    Just start another copy with Shell and then terminate.

    Or is there something more you haven't told us yet?

  4. #4
    Junior Member
    Join Date
    Aug 2014
    Posts
    30

    Re: Restarting my VB6 Program

    Is this serious? you can fake it by making two forms, the first form will be hidden(transparent) this will call your second form (main) in restarting.

  5. #5
    Registered User
    Join Date
    Sep 2014
    Posts
    1

    Re: Restarting my VB6 Program

    After unloading the main form reload it again

    Private Sub Commantd1_Click()
    Unload me
    Form_Load
    End Sub

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Restarting my VB6 Program

    If I had to guess I'd think either the program has memory leaks and other issues and needs to be restarted every so often before it crashes or locks up, or else this is part of some kind of program self-update process.

    Form fiddling won't help in either case, nor in many other rarer scenarios.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Restarting my VB6 Program

    I'm curious about the reason behind it too... because that could potentially dictate what the solution ends up being.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2012
    Posts
    433

    Re: Restarting my VB6 Program

    Thanks.
    It seems this is only way.

    Code:
    If (...) Then
       Shell "MyProgram.exe"
       End
    End If
    The reason why I try this is that there's an option to choose language in the preference of my program.
    For example, if choose "French", program should be terminated and restart to read the language file and load on the memory which is to be applied to the French texts of my program.

    Is there any other better way?

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Restarting my VB6 Program

    I'd avoid the End statement and exit cleanly to avoid potential loss of data, but aside from that this might be a pretty convenient approach.

    It depends on how much work it would be to just start using the new "language file" without restarting.

  10. #10
    Lively Member nthski's Avatar
    Join Date
    Aug 2014
    Posts
    83

    Re: Restarting my VB6 Program

    Code:
    Private Sub Command1_Click()
    If opt1.Value = True Then
    Me.Caption = "Hello"
    Me.Visible = False
    Call restart
    ElseIf opt2.Value = True Then
    Me.Caption = "Hola"
    Me.Visible = False
    Call restart
    End If
    End Sub
    Sub restart()
    Timer1.Enabled = True
    End Sub
    
    Private Sub Form_Load()
    Timer1.Enabled = False
    End Sub
    Private Sub Timer1_Timer()
    Form1.Visible = True
    End Sub
    1 form
    2 option button name opt1 and opt2
    1 timer set value 300 ' or any value you want
    You can measure a programmer's perspective by noting his attitude on the continuing vitality of FORTRAN.

  11. #11
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Restarting my VB6 Program

    That doesn't actually do anything but hide the form and then re-show it... that's not the same as restarting.

    Again, until we know what the OP's intentions are, there's no point in providing any answers.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width