diddom 发表于 2012-6-6 07:45:55

The UBound function

<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>

马大哈 发表于 2012-6-9 22:14:34

.....这是啥东东?VBS?

kk1025 发表于 2013-4-12 22:57:17

看不太懂這在做什麼
页: [1]
查看完整版本: The UBound function