Results 1 to 4 of 4

Thread: Sensible form management

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    London, UK
    Posts
    4

    Sensible form management

    I'm trying to find a sensible form management method to allow referencing methods across forms. In brief here's my problem:

    Traditionally I've always done this by declaring the form containing the element I want to reference as a local variable at the point of reference. So kind of like this:
    Code:
    Dim form as frmReference = frmReference.ActiveForm
    . Which is great, except this will only work when referencing between two forms where one of the forms called the other. Not exactly useful for any project with >2 forms, and even when it does work it quickly becomes horribly messy.

    This started becoming unusable within my current project today, so I tried a different tact. Created a class to hold references to all my forms, whereby each form has a decleration within the class to which they assign themselves when they launch
    Code:
    clFormLib.frmReference = Me in frmReference_load
    Great, a lot neater solution and if a form's open then I can now access it and its properties from anywhere. Except I can't. Because now the compiler refuses to acknowledge that the elements I am trying to reference on these forms exist, because of course the variables which hold the form references aren't assigned to anything before the application is running. So now I can't compile anything!

    Can anyone suggest a better form management method to allow me to reference elements through multiple forms within in the application?

    Thanks.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    In a module:

    Public frm1 as New frmSomeName
    Public frm2 as New frmSomeOtherName
    Public frm3 as new frmMoreName

    Sub Main
    Application.run(frm1)
    End Sub

    In frmSomeOtherName 'for example

    Private Sub DoSomething()
    strSomething = frm1.txtID.text
    strElse = frm3.txtName.text
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Location
    London, UK
    Posts
    4
    You mean to use the module containing the form references as the initially loaded object then I presume?

    Surely by declaring them as new forms at the outset this will mean that they are all loaded into memory? Which could equal quite a bit of performace degradation?

    I shall have a play with this idea though, thankyou.

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    You could declare it in another form, say

    In frmSomeOtherName

    dim frm3 as new frmMoreName
    frm3.txtName = strName

    You can do this, but if you declare a new frmMoreName in another form, you'll now have two instances of frmMoreName, probably not what you want.

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