[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Restarting a form in VB6

Posted on 2012-12-24
10
Medium Priority
?
338 Views
Last Modified: 2012-12-27
I am trying to unload my form and start over.  Why doesn't the following code work?  It simply ends the program


Splash4.Show
            
            Unload CAPOrganizing
            
            Load CAPOrganizing
            
            Splash4.Hide

Open in new window

0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 500 total points
ID: 38718992
if Splash4 is your loading/first form, ending it also ends the program
0
 

Author Comment

by:al4629740
ID: 38719019
I don't understand what your saying exactly.  Can you explain that again?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38719052
what is your starting form? which one is set in the project properties?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Assisted Solution

by:eemit
eemit earned 500 total points
ID: 38719253
You also need:
CAPOrganizing.Show
0
 

Author Comment

by:al4629740
ID: 38719325
my first form is a splash screen also called Splash1

Would it be instead

            Splash4.Show
           
            Unload CAPOrganizing
           
            CapOrganizing.Show
           
            Splash4.Hide
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 38719410
Why do you want to start over and what exactly do you mean by "start over". End the program and restart it, or something else?
0
 

Author Comment

by:al4629740
ID: 38719511
I would like to basically unload and load the form again....
0
 
LVL 28

Assisted Solution

by:Ark
Ark earned 1000 total points
ID: 38719566
Would it be instead
            Splash4.Show
            Unload CAPOrganizing
            CapOrganizing.Show
            Splash4.Hide
Exactly. The only addidion may be

CAPOrganizing.Hide 'In case unloading takes a wile - hide form if it's visible and show splash
Splash4.Show
Unload CAPOrganizing 'etc
But in most cases youdon't need reload form. If you have some code in Form_Load event - place it in some Public Sub, smth like this:
Private Sub Form_Load()
   InitForm
End Sub
Public Sub InitForm(probably_some_initial_value As Something)
   'Your initializing/updating/refreshing code here
End Sub

Open in new window

And instead of reloading form just call
CAPOrganizing.InitForm(conditions)
0
 

Author Comment

by:al4629740
ID: 38719658
How does initform work?

What do I put for conditions?
0
 
LVL 28

Accepted Solution

by:
Ark earned 1000 total points
ID: 38720563
Why do you need to reload form? In most cases you just need to execute code in Form_Load event. So you can move all this code into InitForm sub:
Was:
Private Sub Form_Load()
  'A lot of initializing code here
End Sub

Open in new window

Should be:
Private Sub Form_Load()
  Call InitForm(0) '0 means you call InitForm for the first time, from withing Form_Load Event 
End Sub
Public Sub InitForm(condition As Long)
  'A lot of initializing code here
End Sub
'Any time you need 'Reload' form
Call YourFormName.InitForm(1) 

Open in new window

Condition parameter is optional, just in case you need to tell InitForm Sub to execute or not some staff according to your needs, for example, during first call (condition=0) populate listbox/ComboBox with values and set .ListIndex=0, while for other calls leave populated controls as they are and set .ListIndex = some other value.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question