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
    
  • 相关阅读:
    关于Python的装饰器(1)
    Linux环境配置备忘
    Spark实施备忘
    RuntimeError: Python is not installed as a framework 错误解决方案
    使用正则表达式验证素数
    Linux终极shell-zsh的完美配置方案!——oh-my-zsh
    终极之shell-zsh全解析
    linux下IPTABLES配置详解
    一款堪称完美的编程字体Source Code Pro
    Linux中一个文件10行内容,如何输出5-8内容到屏幕
  • 原文地址:https://www.cnblogs.com/1148510216yong/p/9387570.html
Copyright © 2011-2022 走看看