Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use VB.Net assignment statement

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to use the VB.Net assignment statement. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Simple assignment statement

Simple assignment statements are basically not much different from previous VB.Net assignment statements, except that VB.Net now allows you to assign values immediately after a variable is declared (you can see the example in the previous accessibility example). What we need to focus on is the declaration and assignment of the array. In VB.Net, when you declare an array, you can describe both the latitude and the upper limit of the array, and the lower limit of the latitude of each array is 0, which cannot be changed. However, you can specify a zero-length array by specifying the upper limit of the array to-1. This array does not contain any elements.

If the length of the array is not displayed, you can assign a value immediately while declaring the array.

Examples of declaration and assignment of array

Public Class TestA Dim iArr () As Int32 Dim bArr (5) As Boolean'5 refers to the upper limit of bArr subscript, that is, there can be six elements Dim lArr () As Long = New Long (3) {100,200,300,400} Dim cArr () As String = New String () {"A", "B", "C"} Dim dArr (- 1) As Double End Class

More features of arrays will be described in more detail in a later introduction to arrays.

Compound assignment

Now VB.Net starts to support compound assignment statements. Unlike a fully expanded expression, the variable to the left of the compound assignment statement is evaluated only once. This means that at run time, the variable expression evaluates before the expression to the right of the assignment statement.

An example of compound assignment

Public Class TestA Public Sub New () Dim i As Int32 I + = 10 End Sub End Class

Mid assignment

Mid assignment is actually the process of string assignment. You can understand how Mid is assigned through the following examples.

Public Class TestA Public Sub New () Dim TmpStr As String TmpStr = "Hello VB.Net" 'Hello VB.Net Mid (TmpStr, 7,2) = "c #"' Hello c#.Net Mid (TmpStr, 7) = "VB6" 'Hello VB6Net Mid (TmpStr, 7) = "VB6 to VB.Net"' Hello VB6 to Mid (TmpStr, 7,3) = "VB6 to VB.Net" 'Hello VB6 to End Sub End Class on how to use VB.Net assignment statements "ends here Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report