VB.NET可選參數的默認值必須是一個常數表達式。
創新互聯于2013年開始,先為舞鋼等服務建站,舞鋼等地企業,進行企業商務咨詢服務。為舞鋼企業網站制作PC+手機+微官網三網同步一站式服務解決您的所有建站問題。
過程定義中跟在可選參數后的每個參數也都必須是可選的。
下面的語法顯示帶VB.NET可選參數的過程聲明:
Sub sub name(ByVal parameter 1 As data type 1,
Optional ByVal parameter 2 As data type 2 = default value)
調用帶VB.NET可選參數的過程
過程在運行時無法檢測到給定的參數是否已被省略,或者調用代碼是否已顯式提供默認值。如果需要弄清楚這一點,可以設置一個不可能的值作為默認值。下面的過程定義了可選參數 office,并測試其默認值 QJZ 以查看它在調用中是否已被省略:
Visual Basic
Sub notify(ByVal company As String, Optional ByVal office As String = "QJZ")
If office = "QJZ" Then
Debug.WriteLine("office not supplied -- using Headquarters")
office = "Headquarters" End If
' Insert code to notify headquarters or specified office.
End Sub
如果可選參數是像 String 這樣的引用類型,只要它不是該變量所預期的值,就可以使用 Nothing 作為默認值。
VB.NET可選參數和重載
定義帶可選參數的過程的另一種方法是使用重載。如果有一個可選參數,可以定義過程的兩個重載版本,一個接受此參數,另一個則不帶參數。此方法隨可選參數數目的增加而變得更復雜。然而,這樣做的優點是可以完全確定調用程序是否提供了每個VB.NET可選參數。
這個只能是一一判斷的:
為了敘述簡單,假設有兩個可選條件,內容在: TextBox1(姓名)、TextBox2(部門)
主要是構造 Sql的Where子句,那么:
Dim MySqlWhere As String
MySqlWhere=""
If TextBox1.Text"" Then
MySqlWhere= " Where 姓名 = '" TextBox1.Text "'"
End If
If TextBox2.Text"" Then
if MySqlWhere="" Then
MySqlWhere= " Where 部門 = '" TextBox1.Text "'"
Else
MySqlWhere= MySqlWhere " And 部門 = '" TextBox1.Text "'"
End If
End If
'如果還有第3,第4,那只能這樣了:
If TextBox3.Text"" Then
if MySqlWhere="" Then
MySqlWhere= " Where 字段3 = '" TextBox3.Text "'"
Else
MySqlWhere= MySqlWhere " And 字段3 = '" TextBox3.Text "'"
End If
End If
......
If TextBoxn.Text"" Then
if MySqlWhere="" Then
MySqlWhere= " Where 字段n = '" TextBoxn.Text "'"
Else
MySqlWhere= MySqlWhere " And 字段n = '" TextBoxn.Text "'"
End If
End If
注意:對于字符類型的字段,當然要用單引號,上面那樣的,但是對于數值類型,就不要這個單引號的;但是對于日期類型,那么與字符類型不同的是,把前后的2個單引號,改為井號就是“#”, 這是很多初學者容易忽略的,也是很多教科書上不提的問題。
對于文本框,由于.NET不提供控件數組,但是還是可以用語句來實現類似數組的操作,這樣以上IF語句,就可以簡化。
首先沒有這個單詞
tide
n.
潮汐, 潮
潮流; 趨勢; 危機或危險狀態
輪流升降或增減的事物
時期, 季節(多用于復合詞, 如:wintertide 冬季, eventide 黃昏)
(宗教上的)節期
at high [low] tide
處于高[低]潮
the tide of history
歷史的潮流
the tide of events
情勢
Christmas tide
圣誕節節期
Time and tide wait for no man.
[諺]歲月不等人; 天道不可抗。
習慣用語
attempt to go against the tide of history 倒行逆施
double tides 夜以繼日地(與動詞 work 連用) 狂怒地, 猛烈地(通常與動詞roar連用)
catch thetide 趁機
floodtide 漲潮;(事業、成就等的)頂點,高峰
flowing tide 漲潮 正在增長、推進的事物
full tide of pleasure 歡樂的絕頂
go [row] against the tide 反潮流, 排除俗見; 在逆境中工作
go with the tide 順應潮流; 隨波逐流; 趕潮流
roll back the tide of war 擊退侵略
save the tide 趁漲潮進出港口
stem thetide[current] 逆流而上 反潮流
swim with thetide 隨波逐流, 隨大流
tail to the tide (船只停泊中)隨潮起而掉頭
take the fortune at the tide (=take the tide at the flood) 及時利用時機, 因利乘便
The tide turns. 形勢轉變, 局面改觀。
turn the tide 改變形勢, 改變局面使事態急轉直下
tide over [口](使)克服(困難), 使渡過(難關、危機等)
收起更多詞典展開更多詞典
現代英漢詞典tide
n.
潮水,潮汐
The tide is down.
潮退了。
At high tide the sea covers the rocks, but at low tide it uncovers them.
海水在高潮位時淹過了礁石,可是在低潮位時卻淹不過。
潮流;浪潮
詞性變化
vt.
tided, tiding
(與over連用)渡過(難關)
習慣用語
swim against the tide 反潮流;開倒車 (= go against the tide)
swim with the tide 順應潮流,隨波逐流 (= go with the tide)
簡明英漢詞典tide
n.
潮, 潮汐, 潮流, 趨勢
柯林斯英語大詞典查詞歷史smiletidesmiletide
tide+{1}
[ta?d]
n
the cyclic rise and fall of sea level caused by the gravitational pull of the sun and moon. There are usually two high tides and two low tides in each lunar daySee tide-generating force See neap tide See spring tide
the current, ebb, or flow of water at a specified place resulting from these changes in level
the tide is coming in
See ebb See flood
a widespread tendency or movement
the tide of resentment against the government
a critical point in time; turning point
the tide of his fortunes
a fair or holiday
a season or time
Christmastide
any body of mobile water, such as a stream
a favourable opportunity
vb
to carry or be carried with or as if with the tide
to ebb and flow like the tide
tide
tide+{2}
[ta?d]
vb
to happen
柯林斯詞典說明
收起更多詞典展開更多詞典
WordNettide
tides tided tiding
Noun
1. the periodic rise and fall of the sea level under the gravitational pull of the moon
(hypernym) periodic event, recurrent event
(hyponym) high tide, high water, highwater
(part-meronym) tidal flow, tidal current
2. something that may increase or decrease (like the tides of the sea); "a rising tide of popular interest"
(hypernym) variation, fluctuation
(derivation) surge
3. there are usually two high and two low tides each day
(synonym) lunar time period
(hypernym) time period, period of time, period
Verb
1. rise or move foward; "surging waves"
(synonym) surge
(antonym) ebb, ebb away, ebb down, ebb out, ebb off
(hypernym) run, flow, feed, course
2. cause to float with the tide
(hypernym) float
(see-also) tide over, bridge over, keep going
3. be carried with the tide
(hypernym) float, drift, be adrift, blow
We agree to comply with the copyright notice and statements mentioned in WordNet license. 百科tide
詞性及解釋
n. 潮, 潮汐, 趨勢, 潮流, 漲潮, 高潮
vt. 使隨潮漂流
vi. 順潮行駛
更多解釋
相關詞條
ebb-tide tide staff neap tide tide curve dead tide spring tide earth tide superior tide tide energy low tide lee tide tide and half tide tide pool tide-rock half tide geomagnetic tide tide clock meteorological tide alkaline tide strain tide flood tide direct tide
該解釋由詞友提供,僅供參考。 免責聲明
與 tide 相關的例句East Scheldt Tide Lock
東斯海爾德擋潮閘
equilibrium theory of tide
平衡潮學說
The tide flow in.
潮水急速涌了進來。
The tide is in.
現在在漲潮。
The tide set in.
漲潮了。
A tide of immigration.
移民潮
It was high tide.
漲潮了。
The tide ebbed away.
潮水退下去了。
The tide has receded.
潮水退了。
The tide has turned.
現在潮流變了。
smile
vi.
微笑(at; on; upon)
譏[冷]笑(at)
眉開眼笑, 表示友好態度
變晴朗, 呈現樂觀氣象
He never smiles.
他從不露笑臉。
Who are you -ling at?
你在笑誰?
He smiled to see her so happy.
看到她這么高興, 他笑了。
習慣用語
be all smiles 笑容滿面, 喜氣洋洋
crack a smile [美口]面帶笑容
ghastly smile 慘笑
I should smile 我才不干呢; 我才不在乎呢 我很高興; 好得很
put a smile on sb.'s face 使某人高興[歡樂]
sardonic smile 嘲笑; 冷笑
(the) smiles of fortune 走運; 吉星高照
take the smiles off sb.'s face 使某人高興不下去; 使某人轉樂為苦
wipe the smiles off sb.'s face 使某人高興不下去; 使某人轉樂為苦
toothpaste smile [美口]牙膏廣告上露出皓齒的微笑
smile at 看著...微笑; 一笑置之
smile away 以微笑消除; 笑著忘掉
smile on 向...微笑
smile upon 向...微笑
收起更多詞典展開更多詞典
現代英漢詞典smile
vi., vt.
smiled, smiling
微笑;露出微笑
She smiled when she saw me.
她看見我時露出微笑。
"At the station, he was told by a smiling policeman that his bicycle had been found."
"在警察局里,一個滿面笑容的警察告訴他,他的自行車找到了。"
呈喜色;顯出好意
Fortune has always smiled at him.
他的命運一向很好。
(與on, upon連用)贊許,鼓勵
詞性變化
n.
微笑,笑容
a smile on his face
他臉上的笑容
簡明英漢詞典smile
vi.
(~ at) 微笑
n.
微笑
柯林斯英語大詞典查詞歷史tidetidesmilesmile
[sma?l]
n
a facial expression characterized by an upturning of the corners of the mouth, usually showing amusement, friendliness, etc, but sometimes scorn, etc
favour or blessing
the smile of fortune
an agreeable appearance
vb
to wear or assume a smile
to look (at) with a kindly or amused expression.to look derisively (at) instead of being annoyed.to bear (troubles, etc) patiently
to show approval; bestow a blessing
to express by means of a smile
she smiled a welcome
to drive away or change by smiling
smile away one's tears
習慣用語
come up smiling to recover cheerfully from misfortune
柯林斯詞典說明
收起更多詞典展開更多詞典
WordNetsmile
smiles smiled smiling
Noun
1. a facial expression characterized by turning up the corners of the mouth; usually shows pleasure or amusement
(synonym) smiling, grin, grinning
(hypernym) facial expression, facial gesture
(hyponym) smirk
Verb
1. change one's facial expression by spreading the lips, often to signal pleasure
(hypernym) grimace, make a face, pull a face
(hyponym) dimple
(derivation) smiling, grin, grinning
2. express with a smile; "She smiled her thanks"
(hypernym) express, show, evince
(derivation) smiling, grin, grinning
We agree to comply with the copyright notice and statements mentioned in WordNet license.
同義詞: beam chuckle grin laugh smirk
反義詞: frown
百科smile
詞性及解釋
n. 微笑, 喜色, 笑容
vi. 微笑, 覺得好笑
vt. 微笑著表示
更多解釋
相關詞條
smile on sardonic smile ghastly smile smile upon smile away smile at I should smile crack a smile an artificial smile a ghost of a smile smile on sb Hanes-Whistle-Smile sign
該解釋由詞友提供,僅供參考。 免責聲明
與 smile 相關的例句A manmay smile and smile and be villain.
笑里藏奸。
His smile disarmed us.
他的微笑消除了我們的怒氣。
A motherlike smile, embrace
慈母般的微笑、擁抱
a sickening sanctimonious smile.
令人作嘔的偽裝神圣的笑容。
A vague smile, gesture
用意不明的微笑、手勢
A villainous plot, smile
邪惡的陰謀、猙獰的笑
Always wears a smile.
總是面露微笑
He forced a smile.
他強作笑顏。
He wore a smile.
他面帶笑容。
Here comes that smile!
那種微笑又來啦!
在邏輯運算中表示 或者
稱作邏輯或
用法 if 1 or 0 then print 111
標題名稱:包含orvb.net的詞條
轉載注明:http://m.kartarina.com/article46/dogeheg.html
成都網站建設公司_創新互聯,為您提供靜態網站、微信小程序、App設計、外貿建站、微信公眾號、響應式網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯