Vbs:class, Public, Private

Source: Internet
Author: User

ClassCircle

     PublicR
     PrivateMArea
    
     Public   SubInit (a)
R=a
     End   Sub
    
     Public   FunctionArea ()
         IfMarea=""   Then  
Marea=Atn(1)*4*r*r
         End   If
Area=marea
     End   Function
        
     Private   SubEchoinfo ()
         MsgBox   "The radius of the circle is:"& R &vbCrLf&"The area of the circle is:"& MArea
     End   Sub  
        
End   Class

Setc =NewCircle' Create a TestClass instance.
C.init2                                 
' Init is the constructor name in Python, you can define other names as you like
' other languages, such as c#,c++, use the class name as the constructor name, and obviously no init is easy to remember .
MsgBoxC.r
MsgBoxC.area ()
' MsgBox C.marea
' cannot be accessed because this field is private and can only be accessed within the class, such as the area method above
' MsgBox c.echoinfo ()
' cannot be accessed because this method is private and can only be accessed within the class
Setc = Nothing        ' Delete instance

Vbs:class, Public, Private

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.