zoukankan      html  css  js  c++  java
  • vb.net学习笔记

    VB.Net学习地址

    https://www.w3cschool.cn/vb_net/vb_net-vxwt1wa9.html

    VB.Net的集成开发环境(IDE)

    • Visual Studio 2013(VS)

    一个VB.Net程序主要由以下几部分组成:

    • 命名空间声明 Namespace declaration
    • 一个类或模块 A class or module
    • 一个或多个程序 One or more procedures
    • 变量 Variables
    • 主过程 The Main procedure
    • 语句和表达式 Statements & Expressions
    • 注释 Comments

    打印单词“Hello World”

    Imports System
    Module Module1
       'This program will display Hello World 
       Sub Main()
          Console.WriteLine("Hello World")
          Console.ReadKey()
       End Sub
    End Module
    

    Rectangle类的实现

    Imports System
    Public Class Rectangle
        Private length As Double
        Private width As Double
    
        'Public methods
        Public Sub AcceptDetails()
            length = 4.5
            width = 3.5
        End Sub
    
        Public Function GetArea() As Double
            GetArea = length * width
        End Function
        Public Sub Display()
            Console.WriteLine("Length: {0}", length)
            Console.WriteLine("Width: {0}", width)
            Console.WriteLine("Area: {0}", GetArea())
    
        End Sub
    
        Shared Sub Main()
            Dim r As New Rectangle()
            r.Acceptdetails()
            r.Display()
            Console.ReadLine()
        End Sub
    End Class
    

    接受来自用户的值

    Module variablesNdataypes
       Sub Main()
          Dim message As String
          Console.Write("Enter message: ")
          message = Console.ReadLine
          Console.WriteLine()
          Console.WriteLine("Your Message: {0}", message)
          Console.ReadLine()
       End Sub
    End Module
    

    声明常量

    Module constantsNenum
       Sub Main()
          Const PI = 3.14149
          Dim radius, area As Single
          radius = 7
          area = PI * radius * radius
          Console.WriteLine("Area = " & Str(area))
          Console.ReadKey()
       End Sub
    End Module
    

    声明枚举

    Module constantsNenum
       Enum Colors
          red = 1
          orange = 2
          yellow = 3
          green = 4
          azure = 5
          blue = 6
          violet = 7
       End Enum
       Sub Main()
          Console.WriteLine("The Color Red is : " & Colors.red)
          Console.WriteLine("The Color Yellow is : " & Colors.yellow)
          Console.WriteLine("The Color Blue is : " & Colors.blue)
          Console.WriteLine("The Color Green is : " & Colors.green)
          Console.ReadKey()
       End Sub
    End Module
    
  • 相关阅读:
    JSOI2015 R3 退队滚粗了
    bzoj3774
    bzoj1426
    bzoj3294
    java 位向量
    java 移位操作
    java 枚举类型的使用
    mysql 修改 root 用户密码
    几种数据库连接池的比较
    linux python 安装 pip出现 No module named 'setuptools'
  • 原文地址:https://www.cnblogs.com/1148510216yong/p/9387570.html
Copyright © 2011-2022 走看看