'*********************************************************
' 目的: 返回指定用户在 userlist 数组中第一次出现的位置。
' 输入: struserlist(): 所查找的用户列表。
' strtargetuser: 要查找的用户名。
' 返回: strtargetuser 在 struserlist 数组中第一次出现时的索引。
' 如果目标用户未找到,返回 -1。
'*********************************************************
function intfinduser (struserlist(), strtargetuser)
dim i ' 循环计数器。
dim blnfound ' 发现目标的标记。
intfinduser = -1
i = 0 ' 初始化循环计数器。
do while i <= ubound(struserlist) and not blnfound
if struserlist(i) = strtargetuser then
blnfound = true ' 标记设为 true。
intfinduser = i ' 返回值设为循环计数器。
end if
i = i + 1 ' 循环计数器加 1。
loop
end function