Results 1 to 5 of 5

Thread: [RESOLVED] Using Callbacks

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    177

    Resolved [RESOLVED] Using Callbacks

    Hi,

    I hope no one minds, but I figured I would create a new thread since my topic and question changed in my previous one.

    I am not working with Callbacks and still very unsure of how they work.

    I looked over the Sample here ---> http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx but it does not all make sense.

    I have a module in my 2nd project like so.

    vb.net Code:
    1. Module ModuleSend
    2.  
    3.     Public Delegate Sub CallKey()
    4.  
    5.     Public SendCallBack As CallKey = Nothing
    6.  
    7.  
    8.     Public Sub Invoke()
    9.         Try
    10.             If Not SendCallBack Is Nothing Then
    11.                 SendCallBack.Invoke()
    12.             End If
    13.         Catch
    14.         End Try
    15.  
    16.     End Sub
    17.  
    18. End Module

    Now I want to be able use this in the main project

    vb.net Code:
    1. ModuleSend.SendKeyCallBack = AddressOf Main.Do

    But even though SendKeyCallBack is declared in the module it says it is not declared. any ideas?
    Last edited by Crzyrio; Jun 5th, 2013 at 02:15 PM.

  2. #2
    New Member
    Join Date
    Jan 2013
    Posts
    2

    Re: Using Callbacks

    Sorry, I don't know much about callbacks but, why is the "Public SendKeyCallBack As CallSendKey = Nothing" ? Looking through the link you posted above it doesn't say anything about any code like that, maybe this is where your problem lies? Or maybe because "CallSendKey" is set to nothing.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    177

    Re: Using Callbacks

    Quote Originally Posted by DamnNation View Post
    Sorry, I don't know much about callbacks but, why is the "Public SendKeyCallBack As CallSendKey = Nothing" ? Looking through the link you posted above it doesn't say anything about any code like that, maybe this is where your problem lies? Or maybe because "CallSendKey" is set to nothing.
    Even when it is set to something it is the same problem.
    EDIT: Silly me, forgot to make the Module public :P
    Last edited by Crzyrio; Jun 5th, 2013 at 10:21 AM.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Using Callbacks

    Modules default to "Friend" in VB.Net, so if you're trying to reference something in it from another project in the solution, it will not be able to resolve it.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    177

    Re: Using Callbacks

    Quote Originally Posted by Niya View Post
    Modules default to "Friend" in VB.Net, so if you're trying to reference something in it from another project in the solution, it will not be able to resolve it.
    Thank You very much Changing it to public solved the problem and I did not know they defaulted to Friend in vb!

    Call backs are an interesting tool.

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