Results 1 to 9 of 9

Thread: Function question.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Question

    I have started out reading books on vb,and i have got a good basic idea how vb works....but! in all my books..it doesnt explain this simple question i have..

    When you create a function,can you "name" it whatever you want? So if i wanted to create a function named
    Formatharddrive() all i would have to do is input the code and will it work?Or is there a predetermined set of functions that we all have to live by.(for vb)
    Thank you in advance for any help.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You can name your functions/Subs/Properties whatever you want
    Code:
    Function Formatharddrive()
       'Your code of the formatting harddrive goes here
    End function
    
    Sub DeleteWindows()
       'Your code goes here
    End sub
    
    Property Get Whatisthisallabout()
        'Your explanations here
    End property
    Feel free to ask more, this site is for you, those books probably don't worth the money you spent on them
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    Pretty much. You have two groups of subs or functions. You have those that execute as a result of an event firing, and those you create, that you call from another sub or function. Those that you create, you can name anything you want except for the names reserved for the event firing ones.
    There is also a difference between functions and subs (sub routines). Functions return an object, subs don't.

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    yep. you can call functions and subs pretty much what you want. Obviously there are some illegal characters and it would be silly to try and name a function the same as one that already exists. but

    Code:
    Private Function Format_Hard_Drive() as Boolean
    End Function
    
    'or
    
    Private Sub I_Hate_Windows()
    End Sub
    Would be fine.
    Iain, thats with an i by the way!

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I forgot to tell if you you will experience problems if you name your methods with the same name as other vb's methods. That's a big problem for newbies
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Guest
    I hope that VB7 will have an option for VB Code Editor to reconize your functions and highlight it in blue. C++ has the ability to do this, I'm sure they can put it in VB.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    that would be nice, but another color, blue is already used
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    meg how do you get C++ to do that.

  9. #9
    Guest
    There is a file that when you add to it, it will highlight whatever word is in it. I forgot the name of the file though .

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