Results 1 to 2 of 2

Thread: Events

  1. #1

    Thread Starter
    Addicted Member soluga's Avatar
    Join Date
    Dec 2005
    Location
    Manchester (Uk)
    Posts
    211

    Events

    I have a solution with multiple projects, one project has a sql querie form in it, when the user builds up the query, I want to be able to pass the query back to the calling form, although I can access the sending form through reference I cannot access any controls on the form or any events, some code I have tried is below, grateful for any advice. Thanks

    VB Code:
    1. Public Class frmquerie
    2.     Inherits System.Windows.Forms.Form
    3.     Event GetSqlStatement()
    4.  
    5. blah blah
    6.  
    7.     Private Sub btnexecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexecute.Click
    8.         RaiseEvent GetSqlStatement()
    9.         _GetSqlString = txtsqlstring.Text
    10.         MsgBox(getsqlstring.ToString)
    11. End Class
    12.  
    13.  
    14. On the other form
    15.  
    16. Public Class frmcolours
    17.     Inherits System.Windows.Forms.Form
    18.     Dim WithEvents _frmquerie As New common.frmquerie
    19.  
    20.  
    21.     Private Sub getthesql() Handles _frmquerie.GetSqlStatement
    22.         TextBox1.Text = _frmquerie.getsqlstring
    23.  
    24.     End Sub
    Last edited by RobDog888; Jan 7th, 2006 at 03:10 PM. Reason: Added [vbcode] tags

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Events

    You seem to be mixing up several concepts together. I wasn't able to understand your code very well at first glance, but you should make the referenced class only return values to the calling class (if at all). Also, when calling a sub, function or event, instead of attempting to access textbox1.text within it, pass it as an argument.

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