superflq 发表于 2008-12-6 15:21:07

请教For...In...Next?

找来找去都找不到For...In...Next的中文使用方法,
哪位知道怎么用,请给个简单的说明,谢谢了

[ 本帖最后由 superflq 于 2008-12-7 16:37 编辑 ]

大绯狼 发表于 2008-12-6 15:27:40

算1+2+3+4+5
$s=0
for $i=1 to 5
    $s+=$i
    msgbox(0,0,"第"&$I&"次累加后S="&$s)
next

liongodmien 发表于 2008-12-6 15:57:09


For...In...Next
--------------------------------------------------------------------------------

Enumerates elements in an Object collection or an array


For <$Variable> In <expression>
    statements
    ...
Next




Parameters

Variable A variable to which an element is being assigned
expression Must be an expression resulting in an Object, or an Array with at least one element



Remarks

The Variable will be created automatically with a LOCAL scope, even when MustDeclareVars is on.
If the expression is an Object collection with no elements, the loop will be skipped and the Variable will contain an empty string.
If the expression is not an Object nor an Array, the script stops with an error, unless a COM Error handler had been configured.

For...In...Next statements may be nested.




Related

With...EndWith, ObjEvent (COM Error handler)


Example


;Using an Array
Dim $aArray

$aArray="a"
$aArray=0
$aArray=1.3434
$aArray="test"

$string = ""
FOR $element IN $aArray
    $string = $string & $element & @CRLF
NEXT

Msgbox(0,"For..IN Arraytest","Result is: " & @CRLF & $string)

;Using an Object Collection

$oShell = ObjCreate("shell.application")
$oShellWindows=$oShell.windows

if Isobj($oShellWindows) then
$string=""

for $Window in $oShellWindows
    $String = $String & $Window.LocationName & @CRLF
next

msgbox(0,"","You have the following windows open:" & @CRLF & $String)
else

msgbox(0,"","you have no open shell windows.")
endif



superflq 发表于 2008-12-6 17:19:00

#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
Next


$oLink.href 这里后面为什么有个.href
我要怎么读取$oLinks,输出到.ini或者.txt
要怎么写

KEYFree2008 发表于 2008-12-6 22:31:35

找下早期的AU3版本中的帮助大部分是中文的:face (16):
页: [1]
查看完整版本: 请教For...In...Next?