Results 1 to 5 of 5

Thread: Calling functions

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    113

    Calling functions

    Form1 has a function called UpdateDisplay() how can I call it from Form2 ?


    Thanks for any advice.

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    The one way that I know of:

    Form1 needs to be a form derived from Form2 meaning Form1 needs to be in code in Form2 something like

    Dim F1 as new Form1

    Then, make the function public. After which, F1.FunctionName should work fine.


    Aside from that, I imagine it would be possible using AddressOf, but I'm not sure how.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    When form1 calls form2 have it pass itself as the Owner then form2 can use that property to access it.

    VB Code:
    1. 'in form1
    2. dim frm as New Form2()
    3. frm.Owner=Me
    4. frm.Show()
    5.  
    6. 'in form2
    7. 'you have to cast to the specific form to access custom items on it
    8. DirectCast(Me.Owner,Form1).UpdateDisplay()

  4. #4
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    Why don't you just put the UpdateDisplay() function in a code module? Then you can call it from both forms.
    ~Peter


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    113
    Edneeis,

    YOU solved my problem !!! Thank you so very very very much !

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