+ Reply to Thread
Results 1 to 3 of 3
  1. Member
    Join Date
    Sep 2007
    Location
    London
    Posts
    37

    Certifications
    MCTS: HyperV\EXCH07\OCS, MCITP:EST Vista+7 \ EMA 2010\ EA, MCSA:M, MCSE, ASC, STS:EV8\9\10, SCS:EV9\10
    #1

    Default Classes\Modules, Functions\Subroutines and general programming best practice

    Hi Guys,

    I'm trying to write an application and had a few questions regarding programming syntax and best practice.

    Programming syntax

    Does anyone have a site \ list of prefixes for different types of object e.g. you put frm before a form, int befor an integer variable etc.

    Funtions \ Subroutines

    Do functions have to have a specific value output for example would the following work as a function and if not why?

    If intEnteredHours > 8 Then
    intStandardHours = 8
    intOverTimeHours = (intHours - intStandardHours)

    Else
    intStandardHours = intEnteredHours
    intOverTimeHours = 0
    End If


    Classes\Modules

    Both of these can be used to store functions and subroutines which can be called later but when would you use each one? Should you spit out all calculation subroutines into classes \ modules for each form and then call them or just leave anything that is form specific as a subroutine \ function of that form?

    Thanks,

    Aron
    Reply With Quote Quote  

  2. SS -->
  3. Member
    Join Date
    Sep 2007
    Location
    London
    Posts
    37

    Certifications
    MCTS: HyperV\EXCH07\OCS, MCITP:EST Vista+7 \ EMA 2010\ EA, MCSA:M, MCSE, ASC, STS:EV8\9\10, SCS:EV9\10
    #2
    OK did a bit of reading. So, the code I put up could only be a subroutine as it only defines values and doesn't return them. So a function would go something like:

    public function Example

    Dim result as string
    dim a as integer

    a = 10

    result = 1 * a

    Return result

    I could then use that function later on in the code by doing something like

    Word = 23 * (call Example)

    Right?

    Also, each form is created with an associated module by default so I would just store all form specific code and procedures in that form and then any non form specific code in a module \ class right? How about global variables, is it best to define them in the form in which they are first called or in a separate module?
    Reply With Quote Quote  

  4. Certification Invigilator Forum Admin JDMurray's Avatar
    Join Date
    Jul 2003
    Location
    Surf City USA
    Posts
    10,597
    Blog Entries
    50

    Certifications
    GSEC, EnCE, CISSP, SSCP, CEH (ANSI), CASP, CCNA, CCENT, CWSP, CWNA, CWTS, Security+, Server+, Network+, A+, DHTI+, PDI+, MSIT InfoSec
    #3
    What language are you using?

    And Microsoft stopped using Hungarian notation many years ago in favor of coding standards commonly used in Java.
    Reply With Quote Quote  

+ Reply to Thread

Social Networking & Bookmarks