Share practical no 18 vb.net

phamanxuan.ngoc

New member
### Thực tế số 18: vb.net

** #vb.net #Programming #tutorial #Examples #thực tế **

## Giới thiệu

Trong thực tế này, chúng ta sẽ học cách sử dụng lớp `math` trong vb.net.Lớp `math` cung cấp một số phương pháp để thực hiện các tính toán toán học, chẳng hạn như các hàm lượng giác, logarit và gốc vuông.

## lớp `math`

Lớp `math` được đặt trong không gian tên` System.math`.Để sử dụng lớp `math`, trước tiên bạn phải nhập không gian tên` system.math` vào dự án của mình.

`` `VBNet
Nhập khẩu Hệ thống.Math
`` `

## Hàm toán học

Lớp `math` cung cấp một số phương pháp để thực hiện các tính toán toán học.Một số phương pháp được sử dụng phổ biến nhất được liệt kê dưới đây.

* `Abs ()`: Trả về giá trị tuyệt đối của một số.
* `Trần ()`: Làm tròn một số lên đến số nguyên gần nhất.
* `Sàn ()`: Làm tròn một số xuống số nguyên gần nhất.
* `Log ()`: Trả về logarit tự nhiên của một số.
* `Pow ()`: Trả về giá trị của một số được nâng lên một nguồn điện.
* `Sin ()`: Trả về sin của một góc.
* `Cos ()`: Trả về cosin của một góc.
* `Tan ()`: Trả về tiếp tuyến của một góc.

## ví dụ

Mã sau đây cho thấy một số ví dụ về việc sử dụng lớp `math`.

`` `VBNet
'Tính giá trị tuyệt đối của -5.
Dim absval là double = math.abs (-5)

'Vòng 3.14159 đến số nguyên gần nhất.
Dim RoundedVal as Integer = math.ceiling (3.14159)

'Vòng 3.14159 xuống số nguyên gần nhất.
Dim RoundedVal2 as Integer = math.floor (3.14159)

'Tính logarit tự nhiên của 2.
Dim lnval as double = math.log (2)

'Nâng 2 lên sức mạnh của 3.
Dim powval dưới dạng double = math.pow (2, 3)

'Tính hình sin 45 độ.
Dim sinval là double = math.sin (45)

'Tính cosin 45 độ.
Dim Cosval là double = math.cos (45)

'Tính tiếp tuyến 45 độ.
Dim tanval dưới dạng double = math.tan (45)
`` `

## Phần kết luận

Trong thực tế này, chúng tôi đã học cách sử dụng lớp `math` trong vb.net.Lớp `math` cung cấp một số phương pháp để thực hiện các tính toán toán học, chẳng hạn như các hàm lượng giác, logarit và gốc vuông.Chúng tôi cũng đã thấy một số ví dụ về việc sử dụng lớp `math`.
=======================================
### Practical No. 18: VB.NET

**#VB.NET #Programming #tutorial #Examples #Practical**

## Introduction

In this practical, we will learn how to use the `Math` class in VB.NET. The `Math` class provides a number of methods for performing mathematical calculations, such as trigonometric functions, logarithms, and square roots.

## The `Math` Class

The `Math` class is located in the `System.Math` namespace. To use the `Math` class, you must first import the `System.Math` namespace into your project.

```vbnet
Imports System.Math
```

## Mathematical Functions

The `Math` class provides a number of methods for performing mathematical calculations. Some of the most commonly used methods are listed below.

* `Abs()`: Returns the absolute value of a number.
* `Ceiling()`: Rounds a number up to the nearest integer.
* `Floor()`: Rounds a number down to the nearest integer.
* `Log()`: Returns the natural logarithm of a number.
* `Pow()`: Returns the value of a number raised to a power.
* `Sin()`: Returns the sine of an angle.
* `Cos()`: Returns the cosine of an angle.
* `Tan()`: Returns the tangent of an angle.

## Examples

The following code shows some examples of using the `Math` class.

```vbnet
' Calculate the absolute value of -5.
Dim absVal As Double = Math.Abs(-5)

' Round 3.14159 to the nearest integer.
Dim roundedVal As Integer = Math.Ceiling(3.14159)

' Round 3.14159 down to the nearest integer.
Dim roundedVal2 As Integer = Math.Floor(3.14159)

' Calculate the natural logarithm of 2.
Dim lnVal As Double = Math.Log(2)

' Raise 2 to the power of 3.
Dim powVal As Double = Math.Pow(2, 3)

' Calculate the sine of 45 degrees.
Dim sinVal As Double = Math.Sin(45)

' Calculate the cosine of 45 degrees.
Dim cosVal As Double = Math.Cos(45)

' Calculate the tangent of 45 degrees.
Dim tanVal As Double = Math.Tan(45)
```

## Conclusion

In this practical, we learned how to use the `Math` class in VB.NET. The `Math` class provides a number of methods for performing mathematical calculations, such as trigonometric functions, logarithms, and square roots. We also saw some examples of using the `Math` class.
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top