国产探花免费观看_亚洲丰满少妇自慰呻吟_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開發資料庫,
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 体育| 和平区| 彰武县| 勐海县| 时尚| 麻栗坡县| 龙陵县| 阜宁县| 阿克陶县| 永昌县| 长治市| 勐海县| 芦山县| 隆子县| 舞钢市| 虹口区| 正镶白旗| 岗巴县| 呈贡县| 巴青县| 监利县| 长沙市| 阜南县| 综艺| 邓州市| 太谷县| 临邑县| 渭南市| 长葛市| 墨竹工卡县| 青龙| 兰溪市| 会昌县| 团风县| 孟津县| 环江| 德兴市| 民勤县| 定州市| 桃江县| 瑞金市|