Results 1 to 3 of 3

Thread: Making a class

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Location
    NY
    Posts
    17

    Making a class

    I'm wanting to use an object-oriented approach in my VB program, so I've been searching around the internet for hours now trying to scrape up information about using VB's classes. As basic a thing as that should be, you'd think it would be documented to heck and back several times over, but I can't find a straightforward answer anywhere. Everything assumes you already know the basics about it.

    So my question is this: how do I make an object (class) in VB? And I have a secondary question; is there anything special about using them in VB that I should know about?

    For example, if I want an object type called MyObj and I want it to have a variable MyVar and the function MySub, how do I do it? My attempt was as the following...
    Code:
    Private Class MyClass
      Public MyVar As Integer
      Public Sub MySub()
      End Sub
    End class
    That didn't work, though I assume that must be because the example I got the idea from was for .NET

    It also doesn't help that whenever I see a code example that uses a class it says "Here is the code for my class" and then lists the innards of it, and never have I seen in the examples yet the code that actually defines the class itself.

    Thanks ahead of time for any help.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    11,044

    Re: Making a class

    Project->Add Class Module
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Making a class

    Your problem finding info is because in VB6 there is no enclosure syntax for modules or classes.

    Also note that while classic VB supports interface implementation, it does not support inheritance, static method/classes, overloading, or indeed most proper OO features. Bear those limitations in mind if you are targeting an OO design

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