Results 1 to 3 of 3

Thread: A Newb Question about Functions

  1. #1

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    A Newb Question about Functions

    I'm new to the world of ".NET" -- fresh out of VB6 I am.

    Anyway, I just spent the past 20 mins trying to write a function and have it called correctly.

    Apparently, I need to build the function within the PUBLIC CLASS frmMain (my main form) ?? Any effort to try and write the function out on it's own just causes issues.

    I just wanted to understand why that is and hopefully grab a high level explanation from someone on how the new coding screen is setup. Let's say I'm writing a function that validates a value entered on my form. Am I correct in putting the function in the form class or should it go elsewhere?

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: A Newb Question about Functions

    all functions and subs need to be inside the class. Outside is used for other stuff such as global-scope variables. To see exactly how a function should be declared, start your project and go to an event handler such as form_load on the right combobox. It will show you where they go.

    Note that this isn't different than vb6. If you were to load up the vb6 form file in a text editor, it's pretty much formatted similar but the IDE hides it.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  3. #3

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Re: A Newb Question about Functions

    Ahhh....

    Makes perfect sense. Thanks.

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