紫水晶编程技术论坛 - 努力打造成全国最好的编程论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 4677|回复: 2

The UBound function

[复制链接]

96

主题

254

帖子

4

精华

核心会员

Rank: 20Rank: 20Rank: 20Rank: 20

积分
6513
发表于 2012-6-6 07:45:55 | 显示全部楼层 |阅读模式
<HTML>
<HEAD>
<TITLE>Dynamic Array Application No.2</TITLE>
<SCRIPT LANGUAGE="vbscript">

Option Explicit            'require all variables to be declared       
ReDim myArray(0)               'create a dynamic array with 1 element
        
Sub cmdButton1_OnClick
   'Store the value enter by the user in the array
   myArray(UBound(myArray)) = Document.frmForm1.txtText1.Value
   'grow the array to be one element greater than its current size
   'Preserve its contents
   ReDim Preserve myArray(UBound(myArray) + 1)
   'Empty the text box for the user
   Document.frmForm1.txtText1.Value = ""
End Sub

Sub cmdButton2_OnClick
   'declare some variables we're going to need
   Dim x, y, strArrayContents
   'repeat this process as many times as there are array elements
   For x = 0 to UBound(myArray) - 1
      'add a short description and the element number to the variable,
      'along with the contents of the element and a carriage return
      strArrayContents =  strArrayContents & "Element No." & CStr(x) & _
                          " = " & myArray(x) & vbCrLf
   'go back and do it again for the next value of x
   Next
  'when we're done, show the result in a message box
   y = MsgBox(strArrayContents,0,"Dynamic Array Application #2")
End Sub

</SCRIPT>
</HEAD>
<BODY BGCOLOR="white">
  <FORM NAME="frmForm1">
   <INPUT TYPE="text" NAME="txtText1"><BR>
   <INPUT TYPE="button" NAME="cmdButton1" VALUE="Add to array"><P>
   <INPUT TYPE="button" NAME="cmdButton2" VALUE="Show Array Contents">
  </FORM>
</BODY>
</HTML>

273

主题

3287

帖子

1

精华

管理员

嗷嗷叫的老马

Rank: 125Rank: 125Rank: 125Rank: 125Rank: 125

积分
17057

论坛牛人贡献奖关注奖最佳版主进步奖人气王疯狂作品奖精英奖赞助论坛勋章乐于助人勋章

QQ
发表于 2012-6-9 22:14:34 | 显示全部楼层
.....这是啥东东?VBS?
我就是嗷嗷叫的老马了......

7

主题

421

帖子

1

精华

铂金会员

Rank: 5

积分
2173
发表于 2013-4-12 22:57:17 | 显示全部楼层
看不太懂這在做什麼
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

手机版|Archiver|紫水晶工作室 ( 粤ICP备05020336号 )

GMT+8, 2024-4-29 21:22 , Processed in 0.022608 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表