国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

Chapter 3 Major VB.NET Changes(2)

2024-07-10 13:02:35
字體:
來源:轉載
供稿:網友
dim txtbillto as textbox
dim txtshipto as textbox
txtshipto =txtbillto
the line of code txtshipto =txtbillto sets the text property of txtshipto to the
value in the text property of txtbillto . but what if that isn’t what you wanted?
what if, instead, you wanted to create an object reference in txtshipto that referred
to the object txtbillto ? you’d have to use this code:
set txtshipto =txtbillto
as you can see, default properties require you to use the set keyword to set refer-ences
from one object variable to another.
vb.net gets around this problem by getting rid of default properties. therefore, to
copy the text property from txtbillto into the text property of txtshipto ,you’d
have to use this code:
txtshipto.text =txtbillto.text
setting the two variables equal to each other sets a reference from one to the other. in
other words, you can set an object reference without the set keyword:
txtshipto =txtbillto ‘ object reference in vb..net
to be more precise, default properties without parameters are no longer supported.
default properties that require parameters are still valid. default properties with para-meters
are most common with collection classes, such as in ado. in an ado exam-ple,
if you assume that rs is an ado recordset, check out the following code:
rs.fields.item(x).value ‘ ok,,fully qualified
rs.fields(x).value ‘ ok,,because item is parameterized
rs.fields(x)‘ error,,because value is not parameterized
the easy solution is to fully qualify everything. this avoids any confusion about
which properties are parameterized and which are not. however, as you know from
your vb days, the number of dots you have should be minimized. the reason is that
each dot requires an ole lookup that slows you down. therefore, you should code
carefully when dealing with parameters.
subs and functions require parentheses
as you saw in the last chapter when you used the msgbox function, you must now
always use parentheses with functions, even if you are ignoring the return value. in
addition, you must use parentheses when calling subs, which you did not do in vb6.
for example, assume that you have this sub in both vb6 and vb.net:
sub foo(byval greeting as string)
‘ implementation code here
end sub
注冊會員,創建你的web開發資料庫,
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云南省| 施秉县| 盖州市| 余江县| 丹江口市| 合肥市| 离岛区| 敦煌市| 高州市| 保康县| 莱州市| 临海市| 区。| 潼南县| 辽阳市| 汉寿县| 双流县| 吉隆县| 当雄县| 绥阳县| 中方县| 大安市| 云龙县| 竹山县| 海安县| 太康县| 阜城县| 开封市| 房产| 邮箱| 天气| 定兴县| 孙吴县| 磐安县| 繁昌县| 旺苍县| 图木舒克市| 临湘市| 普洱| 顺义区| 平安县|