Results 1 to 5 of 5

Thread: i am new to VB

  1. #1

    Thread Starter
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Question i am new to VB

    hey guys, i am new to VB and am very disturbed on how to write modules n classes easily n quickly and what purpose the serve.

  2. #2
    Addicted Member
    Join Date
    Nov 2004
    Posts
    171

    Re: i am new to VB

    Well, I don't know a whole lot about modules, though I have used them, but classes is something I do know a little about. Basically, all a class does is allow you to reuse code. You can create an object from a class. The object then has all of the variables and functions that the class has. The functions can be accessed by the statement object .functionName. Unless I am getting mixed up with c++ anyway. Hope this helps.
    Sherminator ~ I'll be back.

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: i am new to VB

    Quote Originally Posted by Harsh Gupta
    hey guys, i am new to VB and am very disturbed on how to write modules n classes easily n quickly and what purpose the serve.
    If you new to Vb then you do not need to worry about classes for now..

    As for modules well there a way really of keeping code in some form of order for example In a module you can write this

    VB Code:
    1. 'notice its Public so all files in the project can see it
    2. Public Sub SayHello()
    3.     MsgBox("Hello")
    4. End Sub

    Now in a form you can write this
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3.  Call SayHello
    4.  
    5. End Sub

    and it will run through the code in the SayHello() sub

    Best thing you can do is not worry too much about these for now, get to grips with varibles and such like

    Hope that helps and welcome to the forums

  4. #4

    Thread Starter
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: i am new to VB

    i know well enough about variables and contents related to them but i never get to learn about "writing" modules and classes.

    can i write them just like copying api text from "api text viewer"?

  5. #5
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: i am new to VB

    Well, oridnary modules are another way to organize your code. You can have all the 3D stuff in one module, sound stuff in another, physics in another, game engine stuff in another, etc.

    Class modules on the other hand are like objects, only without the objects. You give them properties, methods, and events (optional), but usually can be treated as a regular module only with some limitations, like for example, you can't do arrays. And you can declare a variable as your object. For example, let's say you have a class module called Enemy. Some properties in Enemy could be Visible, Life, Strength, etc. You can have functions/subs for that enemy in there that actually move the enemy. This is optional, but you can even create your own events for that enemy. Then when you are all set, you declare a variable as enemy.

    VB Code:
    1. Public My_Enemy(10) As New Enemy 'Creates 10 enemies

    hope this helps in letting you know the difference in class modules and modules. Don't forget to rate my posts.

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