Solved

Need to reload main form

Posted on 2004-08-31
5
153 Views
Last Modified: 2010-05-02
I currently have a control array of buttons that are dynamically created in the form_load event based on input from a .ini file.  I am providing the user a way to modify this .ini file within my application.  however, if they add or delete an entry from the file, i have no way to be able to update the buttons on the main form to reflect this.

I thought about moving the button creation code into the Paint event, but it won't let me remove controls from there.

Only solution I could come up with is to launch another instance of my application and close the existing one.  It seems kinda crude though, and I'd like to find a better way.  Any suggestions?
0
Comment
Question by:porkVT
5 Comments
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 11942327
You could create a subroutine on your form which is responsible for unloading any existing buttons, then loading them based on the ini file. Call this subroutine from your form_load and from wherever you get notified that the ini file has changed.

Zaphod.
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11942551
Have an application level variable in a module called something like
Public frmMainRef As frmMain

Have a procedure in a module called say ReloadMainForm

With the following code in the module:
Option Explicit
Public frmMainRef As Form1

Public Function ReloadMainForm()
    Set frmMainRef = New Form1
    frmMainRef.Show
End Function


And the following code in the form and a command button:

Option Explicit
Private Sub Command1_Click()
    Unload Me
    ReloadMainForm
End Sub


Everything in your application that needs to refer to the main form should just refer to the global variable frmMainRef.

JR
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12561047
PAQed with no points refunded (of 250) %%STAMP%%

Computer101
EE Admin
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

708 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now