Vb. NET Learning Notes (basic concepts and syntax)

Source: Internet
Author: User
Tags constant inheritance modifier variables require
Notes | concepts | Grammar begins with basic concepts and grammar


Learning a language, especially now is the development of visualization, but I suggest that it is not urgent to drag a few controls first, but the sense of the first to understand the concept of the language, grammar and norms.

Vb. NET is very close to the previous VB6, but since the vb.net is a new object-oriented language, there are some differences between the two.

As you know, now that vb.net has fully supported a variety of object-oriented features, and there are some of the features that other. NET environments require: inheritance, overloading, overriding properties and methods, implementing constructors and destructors, interfaces, delegates, exceptions, namespaces, assemblies, feature programming, multiple threads, Shared members. (We'll explore these features step-by-step in our notes later.) )



Let's briefly describe the vb.net syntax, although it's so much like VB6. So the statement about vb.net is actually a review of the VB6 statement, but some statements are not originally VB6.



Vb. NET statements are: Declaration statements, assignment statements, conditional statements, circular statements, array processing statements, exception statements, control flow statements, call statements, lock statements





Declaration statement
In vb.net, the declaration of a variable is often referred to.

For local variables We declare using the Dim modifier. And you can still use the const modifier to modify the variable to be constant, static as a description of statically variable still valid.



Declaration examples (for class and array we describe later)

Const s as String = "Hello" ' constant local variable

Dim B as Boolean ' rule local variable

Static I as Int32 ' stationary local variable





Accessibility of variables
The three variables above are local variables, and we know that local variables are visible only in the area where they are declared, and that they are inaccessible outside of the scope, and for those controls that require more access, VB. NET provides richer modifier keywords.



accessibility adornments
Describe

Public
Declares that the element is public and has no restrictions on the accessibility of public elements.

Private
Declaring an element can only be accessed from within the same module, class, or structure.

Protected
Declaring an element can be accessed only from within the same class, or from a derived class of that class.

Friend
Declaring elements can be accessed from within the same project, but not from outside the project.

Protected Friend
Declaring elements can be accessed from a derived class or within the same project or both.





Accessibility examples (note the relationship between TESTB,TESTC and Testa)

Public Class Testa

Public I as Int32 = 100 ' access unrestricted

Private s as String = "Hello" ' only Testa can access

Protected B as Boolean = True ' only Testa and its derived classes can access

Friend D as Double = 3.1415926 ' Only the same project class can access

Protected Friend L as Long = 100000 '

End Class





Public Class Testb

Inherits Testa ' Inheritance Testa

Public Sub New ()

mybase.b = False

MYBASE.D = 3.14

MYBASE.I = 10

MYBASE.L = 10000

End Sub

End Class





Public Class TESTC

Public Sub New ()

Dim A as New Testa

A.D = 3.14

A.I = 10

A.L = 1000

End Sub

End Class




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.