Results 1 to 9 of 9

Thread: What would stop a Public Function being seen?

  1. #1

    Thread Starter
    Lively Member bcass's Avatar
    Join Date
    Dec 2007
    Location
    Island of Dots
    Posts
    108

    What would stop a Public Function being seen?

    I have a form (frmA) that has a public function in it, which is declared like this:

    Public Function Init() As Boolean

    In the code of another form (frmB) when I type frmA. VB isn't showing me a list of public functions declared in frmA. I've inherited frmA from someone else. Is there some option or other in VB that is stopping frmB from seeing the Init function in frmA? I've not had this problem before, I can refer to other public functions in other forms without problems.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What would stop a Public Function being seen?

    I have never seen it before either. Zip up the two forms and attach them.

  3. #3
    Addicted Member
    Join Date
    Mar 2008
    Posts
    143

    Re: What would stop a Public Function being seen?

    i believe some reference may be missing, try this add another form in your project and copy all the codes from frmA to the new form and now try to call it from form b, or else just press Ctrl + F5 to find any problem with the code.
    HTH

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What would stop a Public Function being seen?

    The only reference require to access a Public Sub/Function on a different form is the form name. Example:
    Code:
    'On Form1
    Private Sub Command1_Click()
    Form2.ShowIt
    End Sub
    
    'On Form2
    Public Sub ShowIt()
    MsgBox "I am actually on Form2"
    End Sub

  5. #5
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: What would stop a Public Function being seen?

    Sometimes an error somewhere in your code will prevent intellisense (the little dropbox that shows a list of functions/properties etc) from showing.

    Save your project and try to compile and see if you have any errors.

  6. #6

    Thread Starter
    Lively Member bcass's Avatar
    Join Date
    Dec 2007
    Location
    Island of Dots
    Posts
    108

    Re: What would stop a Public Function being seen?

    There are no errors as it runs fine for debug. I can't post the forms here as the company I'm doing the work for wouldn't be very happy with that...

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What would stop a Public Function being seen?

    Quote Originally Posted by bcass
    I can't post the forms here as the company I'm doing the work for wouldn't be very happy with that...
    Then there probably isn't much we can do. The problem you are describing is very odd and without being able to see it for ourselves our ability to provide suggestions is greatly limited.

    If you open a new project, add two forms, add a public sub to one of them, can you call that from the other form?

    I suspect you can.

  8. #8

    Thread Starter
    Lively Member bcass's Avatar
    Join Date
    Dec 2007
    Location
    Island of Dots
    Posts
    108

    Re: What would stop a Public Function being seen?

    That's the weird thing, I'm not having problems calling other public subs/functions from/between other forms. I'll try dumping the objects/code into a new form to see if that fixes it.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What would stop a Public Function being seen?

    Quote Originally Posted by DigiRev
    Sometimes an error somewhere in your code will prevent intellisense (the little dropbox that shows a list of functions/properties etc) from showing.
    This is a very good point.

    If you have error trapping on, turn it off, and see if you can generate any runtimes that might be causing you problems.

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