100、当以下代码执行后,数组中每个下标对应的元素值是什么?代码如下:Dim intJellyBeans() As Integer = {23, 77, 89, 124, 25} intJellyBeans(3) = 59 ReDim Preserve intJellyBeans(6) intJellyBeans(2) = 24
数组元素值依次为:
-
intJellyBeans(0) = 23 -
intJellyBeans(1) = 77 -
intJellyBeans(2) = 24 -
intJellyBeans(3) = 59 -
intJellyBeans(4) = 25 -
intJellyBeans(5) = 0 -
intJellyBeans(6) = 0
因为数组初始值为 {23, 77, 89, 124, 25} ,将索引 3 的元素改为 59 ,使用 ReDim Preserve 扩展数组到 7 个元素(索引 0 - 6 ),保留原元素值,新增元素默认值为 0 ,最后将索引 2 的元素改为 24 。
101、在一个整数数组中,数组元素为 {456, 398, 412, 508, 612},以下代码行将显示什么值?代码为:Dim intInsuranceQuotes() As Integer = {456, 398, 412, 508, 612} lblResult.Text = “The Insurance Rate is ” & _ (intInsuranceQuotes(intInsuranceQuotes.Length - 1))
The Insurance Rate is 612
102、代码 For intRecordCount = 0 To datInventory.Rows.Count ' Processing statements Next 旨在遍历数据库表中的每一行,请修正代码中的错误。
原代码的错误在于循环的结束条件, datInventory.Rows.Count 表示行数,但索引是从0开始的,所以最后一行的索引是 datInventory.Rows.Count - 1 。应将代码修改为:

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



