日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 默认站点!

默认站点

當前位置: 首頁 >

VB2010 的隐式续行(Implicit Line Continuation)

發布時間:2023/11/29 39 豆豆
默认站点 收集整理的這篇文章主要介紹了 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

總結

以上是默认站点為你收集整理的VB2010 的隐式续行(Implicit Line Continuation)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得默认站点網站內容還不錯,歡迎將默认站点推薦給好友。