Polymorphism in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunbalait
    New Member
    • Feb 2007
    • 164

    #1

    Polymorphism in VB

    Hi all

    Somebody please give me a small code for polymorphism concept in vb6.0

    Can we do polymorphism in VB?

    We have to achieve polymorphism without using any cls or bas modules

    THanx
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    Originally posted by arunbalait
    Hi all

    Somebody please give me a small code for polymorphism concept in vb6.0

    Can we do polymorphism in VB?

    We have to achieve polymorphism without using any cls or bas modules

    THanx
    If you don't want using CLS module, so it's not OOP. But it's available to store information without using Class. You will be using Structure. Let see
    Code:
    Type structName
              memberVarrialbe1 As Long
              memberVarriable2 As String
    End Type
    Dim V1 As structName
    'now, store info into struc
    Private Sub Form_Load()
         V1.memberVarriable1 = 100
         V1.memberVarriable2 = "abcdef...."
    End Sub

    Comment

    • arunbalait
      New Member
      • Feb 2007
      • 164

      #3
      Originally posted by pureenhanoi
      If you don't want using CLS module, so it's not OOP. But it's available to store information without using Class. You will be using Structure. Let see
      Code:
      Type structName
                memberVarrialbe1 As Long
                memberVarriable2 As String
      End Type
      Dim V1 As structName
      'now, store info into struc
      Private Sub Form_Load()
           V1.memberVarriable1 = 100
           V1.memberVarriable2 = "abcdef...."
      End Sub
      ya fine

      But am getting error for defining the Type.

      Couldnot define a public-user defined type within a private object module.

      How to define the type here?

      Thanx

      Comment

      • pureenhanoi
        New Member
        • Mar 2007
        • 175

        #4
        Originally posted by arunbalait
        ya fine

        But am getting error for defining the Type.

        Couldnot define a public-user defined type within a private object module.

        How to define the type here?

        Thanx
        If you define a structure within a Form, add "Private" keyword before "Type"
        Private Type ASTRUCTURE_TYPE
        ...
        End Type
        If you want it to be public, define structure within a Module.

        Comment

        • arunbalait
          New Member
          • Feb 2007
          • 164

          #5
          Originally posted by pureenhanoi
          If you define a structure within a Form, add "Private" keyword before "Type"
          Private Type ASTRUCTURE_TYPE
          ...
          End Type
          If you want it to be public, define structure within a Module.
          Ya thanx

          I got it now...

          Thanx for your idea. So in VB only OOP is obtained by using modules. RIght?

          Comment

          Working...