VB2010 的隱式續行(Implicit Line Continuation)

VB2010 的隱式續行(Implicit Line Continuation)

許多情況下,您可以讓 VB 后一行繼續前一行的語句,而不必使用下劃線(_)。下面列舉出隱式續行語法的使用情形。

1、逗號“,”之后

Public?Function?GetUsername(ByVal?username?As?String,
????????????????????????????
ByVal?delimiter?As?Char,
????????????????????????????
ByVal?position?As?Integer)?As?String

????
Return?username.Split(delimiter)(position)
End?Function

2、左括號之后,或右括號之前:
???
Dim?username?=?GetUsername(
????Security.Principal.WindowsIdentity.GetCurrent().Name,
????
CChar("\"),
????
1
??)

3、左大括號之后,或者右大括號之前:?? ?

Dim?customer?=?New?Customer?With?{
??.Name?
=?"Terry?Adams",
??.Company?
=?"Adventure?Works",
??.Email?
=?"terry@www.adventure-works.com"
}

4、XML 文本中的開嵌入表達式(open embedded expression)“<%=”之后,或者閉嵌入表達式(close of an embedded expression)“%>”之前:


Dim?customerXml?=?<Customer>
??????????????????????
<Name>
??????????????????????????
<%=
??????????????????????????????customer.Name
??????????????????????????%
>
??????????????????????
</Name>
??????????????????????
<Email>
??????????????????????????
<%=
??????????????????????????????customer.Email
??????????????????????????%
>
??????????????????????
</Email>
??????????????????
</Customer>

5、字符串連接符“&”之后
?? ?
cmd.CommandText?=
????
"SELECT?*?FROM?Titles?JOIN?Publishers?"?&
????
"ON?Publishers.PubId?=?Titles.PubID?"?&
????
"WHERE?Publishers.State?=?'CA'"

6、賦值符號之后,如(=, &=, :=, +=, -=, *=, /=, \=, ^=, <<=, >>=)
?? ?
Dim?fileStream?=
??My.Computer.FileSystem.
????OpenTextFileReader(filePath)

7、表達式中二元運算符之后,如(+, -, /, *, Mod, <>, <, >, <=, >=, ^, >>, <<, And, AndAlso, Or, OrElse, Like, Xor)
?? ?
Dim?memoryInUse?=
??My.Computer.Info.TotalPhysicalMemory?
+
??My.Computer.Info.TotalVirtualMemory?
-
??My.Computer.Info.AvailablePhysicalMemory?
-
??My.Computer.Info.AvailableVirtualMemory

8、Is 或 IsNot 運算符后
?? ?
If?TypeOf?inStream?Is
??IO.FileStream?
AndAlso
??inStream?
IsNot
??
Nothing?Then

????ReadFile(inStream)

End?If

9、成員修飾符(member qualifier character)“.”之后,并且在成員名稱之前。然而,當您使用 With 語句或者給類型的初始化列表(initialization list)提供成員時,必須在成員修飾符“.”后面加上下劃線“_”。當您使用 With 語句或對象初始化列表(object initialization lists)時,可以在賦值符號(如“=”)后面換行。
?? ?

Dim?fileStream?=
??My.Computer.FileSystem.
????OpenTextFileReader(filePath)

...


'?不允許這樣:
'
?Dim?aType?=?New?With?{?.
'
????PropertyName?=?"Value"

'?可以這樣:
Dim?aType?=?New?With?{.PropertyName?=
????
"Value"}



Dim?log?As?New?EventLog()

'?不可以這樣:
'
?With?log
'
????.
'
??????Source?=?"Application"
'
?End?With

'?可以這樣:
With?log
????.Source?
=
??????
"Application"
End?With

10、XML 軸屬性修飾符(XML axis property qualifier)后面,如“.”、“.@”、“...”的后面。然而,當你使用 With 關鍵字時,標識成員修飾符,你必須包含下劃線。
?? ?
Dim?customerName?=?customerXml.
??
<Name>.Value

Dim?customerEmail?=?customerXml...
??
<Email>.Value

11、標識屬性類(Attribute)時,小于號(<)之后或者大于號(>)之前。還有標識屬性類時,大于號后面也可隱藏連接符。但是,當您標識程序集級別或者模塊級別的屬性類時,必須用連接符“_”。
?? ?
<
Serializable()
>
Public?Class?Customer
????
Public?Property?Name?As?String
????
Public?Property?Company?As?String
????
Public?Property?Email?As?String
End?Class

12、查詢運算符(query operators)之前或之后,包括 Aggregate, Distinct, From, Group By, Group Join, Join, Let, Order By, Select, Skip, Skip While, Take, Take While, Where, In, Into, On, Ascending, and Descending。若查詢運算符由多個單詞構成,您不可以在它們中間換行,如Order By, Group Join, Take While, 和 Skip While。


Dim?vsProcesses?=?From?proc?In
????????????????????Process.GetProcesses
??????????????????Where?proc.MainWindowTitle.Contains(
"Visual?Studio")
??????????????????
Select?proc.ProcessName,?proc.Id,
?????????????????????????proc.MainWindowTitle

13、For Each 語句的 In 關鍵字后
?? ?
For?Each?p?In
??vsProcesses

????Console.WriteLine(
"{0}"?&?vbTab?&?"{1}"?&?vbTab?&?"{2}",
??????p.ProcessName,
??????p.Id,
??????p.MainWindowTitle)
Next
???
14、集合初始化器的 From 關鍵字后

Dim?days?=?New?List(Of?String)?From
??{
???
"Mo",?"Tu",?"We",?"Th",?"F",?"Sa",?"Su"
??}


原文參見:http://msdn.microsoft.com/en-us/library/865x40k4.aspx

轉載于:https://www.cnblogs.com/feixian49/archive/2010/05/17/1737624.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/391687.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391687.shtml
英文地址,請注明出處:http://en.pswp.cn/news/391687.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

flutter bloc_如何在Flutter中使用Streams,BLoC和SQLite

flutter blocRecently, I’ve been working with streams and BLoCs in Flutter to retrieve and display data from an SQLite database. Admittedly, it took me a very long time to make sense of them. With that said, I’d like to go over all this in hopes you’ll w…

leetcode 303. 區域和檢索 - 數組不可變

給定一個整數數組 nums&#xff0c;求出數組從索引 i 到 j&#xff08;i ≤ j&#xff09;范圍內元素的總和&#xff0c;包含 i、j 兩點。 實現 NumArray 類&#xff1a; NumArray(int[] nums) 使用數組 nums 初始化對象 int sumRange(int i, int j) 返回數組 nums 從索引 i …

Bigmart數據集銷售預測

Note: This post is heavy on code, but yes well documented.注意&#xff1a;這篇文章講的是代碼&#xff0c;但確實有據可查。 問題描述 (The Problem Description) The data scientists at BigMart have collected 2013 sales data for 1559 products across 10 stores in…

Android控制ScrollView滑動速度

翻閱查找ScrollView的文檔并搜索了一下沒有發現直接設置的屬性和方法&#xff0c;這里通過繼承來達到這一目的。 /*** 快/慢滑動ScrollView * author農民伯伯 * */public class SlowScrollView extends ScrollView {public SlowScrollView(Context context, Att…

數據特征分析-帕累托分析

帕累托分析(貢獻度分析)&#xff1a;即二八定律 目的&#xff1a;通過二八原則尋找屬于20%的關鍵決定性因素。 隨機生成數據 df pd.DataFrame(np.random.randn(10)*10003000,index list(ABCDEFGHIJ),columns [銷量]) #避免出現負數 df.sort_values(銷量,ascending False,i…

leetcode 304. 二維區域和檢索 - 矩陣不可變(前綴和)

給定一個二維矩陣&#xff0c;計算其子矩形范圍內元素的總和&#xff0c;該子矩陣的左上角為 (row1, col1) &#xff0c;右下角為 (row2, col2) 。 上圖子矩陣左上角 (row1, col1) (2, 1) &#xff0c;右下角(row2, col2) (4, 3)&#xff0c;該子矩形內元素的總和為 8。 示…

算法訓練營 重編碼_編碼訓練營后如何找到工作

算法訓練營 重編碼by Roxy Ayaz由Roxy Ayaz 編碼訓練營后如何找到工作 (How to get a job after a coding bootcamp) Getting a tech job after a coding bootcamp is very possible, but not necessarily pain-free.在編碼訓練營之后獲得技術工作是很有可能的&#xff0c;但不…

dt決策樹_決策樹:構建DT的分步方法

dt決策樹介紹 (Introduction) Decision Trees (DTs) are a non-parametric supervised learning method used for classification and regression. The goal is to create a model that predicts the value of a target variable by learning simple decision rules inferred f…

讀C#開發實戰1200例子記錄-2017年8月14日10:03:55

C# 語言基礎應用&#xff0c;注釋 "///"標記不僅僅可以為代碼段添加說明&#xff0c;它還有一項更重要的工作&#xff0c;就是用于生成自動文檔。自動文檔一般用于描述項目&#xff0c;是項目更加清晰直觀。在VisualStudio2015中可以通過設置項目屬性來生成自動文檔。…

iOS端(騰訊Bugly)閃退異常上報撲獲日志集成與使用指南

app已經上架并且有三次更新版本&#xff0c;今天市場部和顧客約談時&#xff0c;發現顧客的iphone 6 plus iOS 9.0.2上運行app點擊登錄按鈕時直接閃退&#xff0c;無法進入app里&#xff0c;這個問題還是第一次遇到&#xff0c;我下載了相應的模擬器版本&#xff0c; 并在上面運…

數據特征分析-正太分布

期望值&#xff0c;即在一個離散性隨機變量試驗中每次可能結果的概率乘以其結果的總和。 若隨機變量X服從一個數學期望為μ、方差為σ^2的正態分布&#xff0c;記為N(μ&#xff0c;σ^2)&#xff0c;其概率密度函數為正態分布的期望值μ決定了其位置&#xff0c;其標準差σ決定…

leetcode 338. 比特位計數

給定一個非負整數 num。對于 0 ≤ i ≤ num 范圍中的每個數字 i &#xff0c;計算其二進制數中的 1 的數目并將它們作為數組返回。 示例 1: 輸入: 2 輸出: [0,1,1] 示例 2: 輸入: 5 輸出: [0,1,1,2,1,2] 解題思路 偶數&#xff1a;和偶數除以2以后的數字&#xff0c;具有相…

r語言調用數據集中的數據集_自然語言數據集中未解決的問題

r語言調用數據集中的數據集Garbage in, garbage out. You don’t have to be an ML expert to have heard this phrase. Models uncover patterns in the data, so when the data is broken, they develop broken behavior. This is why researchers allocate significant reso…

為什么不應該使用(長期存在的)功能分支

Isn’t the git history in the picture above nice to work with? There are probably many problems in that repository, but one of them is most definitely the use of feature branches. Let’s see how such a bad thing became such a common practice.上面圖片中的g…

(轉) Spring 3 報org.aopalliance.intercept.MethodInterceptor問題解決方法

http://blog.csdn.net/henuhaigang/article/details/13678023 轉自CSDN博客&#xff0c;因為一個jar包沒引入困擾我好長時間 &#xff0c;當時正在做spring AOP 的一個小測試&#xff0c;總在報錯&#xff0c;最后發現自己是問題3&#xff0c;引入一個jar包得到了解決 一 開發環…

數據特征分析-相關性分析

相關性分析是指對兩個或多個具備相關性的變量元素進行分析&#xff0c;從而衡量兩個變量的相關密切程度。 相關性的元素之間需要存在一定的聯系或者概率才可以進行相關性分析。 相關系數在[-1,1]之間。 一、圖示初判 通過pandas做散點矩陣圖進行初步判斷 df1 pd.DataFrame(np.…

leetcode 354. 俄羅斯套娃信封問題(dp+二分)

給定一些標記了寬度和高度的信封&#xff0c;寬度和高度以整數對形式 (w, h) 出現。當另一個信封的寬度和高度都比這個信封大的時候&#xff0c;這個信封就可以放進另一個信封里&#xff0c;如同俄羅斯套娃一樣。 請計算最多能有多少個信封能組成一組“俄羅斯套娃”信封&#…

fastlane use_legacy_build_api true

fastlane版本號&#xff1a;fastlane 1.108.0 Xcode版本號&#xff1a;8.1 MacOS版本號&#xff1a;10.12 使用fastlane打包 - Release / Ad-Hoc包時報錯: [13:36:59]: There was an error exporting your application [13:36:59]: Unfortunately the new Xcode export API is …

獲取所有權_住房所有權經濟學深入研究

獲取所有權Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works without seekin…

scala 單元測試_Scala中的法律測試簡介

scala 單元測試Property-based law testing is one of the most powerful tools in the scala ecosystem. In this post, I’ll explain how to use law testing and the value it’ll give you using in-depth code examples.基于財產的法律測試是scala生態系統中最強大的工具…