• 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
    
  • 相关阅读:
    windows中echo的用法
    通过phpMyAdmin写入MySQL,获取webshell
    底部小鱼特效
    kali Linux的简单介绍
    Kali安装gmpy2
    利用kali生成字典的三种方式
    利用kali嗅探HTTP网页用户账户密码
    永恒之蓝(ms017-010)漏洞利用
    如何使用最新Microsoft Edge打开Flash页面
    结对第二次作业
  • 原文地址:https://www.cnblogs.com/1148510216yong/p/9387570.html
Copyright © 2020-2023  润新知