重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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