Re: Variable Issue by deckhopper
deckhopper
Sat Jan 28 16:44:31 CST 2006
Try the following:
<html>
<head>
<title>Add Users</title>
<HTA:APPLICATION
ID="objBuildUserArray"
APPLICATIONNAME="BuildUserArray"
SCROLL="yes"
SINGLEINSTANCE="no"
WINDOWSTATE="normal">
</head>
<script language="VBScript">
Option Explicit
Dim objShell
Dim arrUsers()
Dim x : x = 0
Set objShell = CreateObject("WScript.Shell")
'Sizes Window on startup
'-------------------------------------------------------
Function Window_OnLoad()
Const iWIDTH = 525
Const iHEIGHT = 450
Window.ResizeTo iWIDTH, iHEIGHT
Window.MoveTo (Screen.availWidth-iWIDTH)/2,_
(Screen.availHeight-iHEIGHT)/2
DataArea1.innerHTML = x
usersTextBox.focus()
End Function
'--------------------------------------------|
'Adds users to an array : checks for empty entry
'-------------------------------------------------------
Sub addUser(user)
If user.Value <> "" And user.Value <> " " _
And user.Value <> " " Then
ReDim Preserve arrUsers(x)
arrUsers(x) = user.Value
x=x+1
DataArea1.innerHTML = x
user.Value = ""
user.focus()
Else
MsgBox "Field Cannot Be Empty!",0,_
"Please Enter User Name"
user.focus()
End If
End Sub
'--------------------------------------------|
'Shows list of users
'-------------------------------------------------------
Sub showUsers()
Dim y,msg
If x <> 0 Then
For y=0 To UBound(arrUsers)
msg = msg & y+1 & ". " & arrUsers(y) & vbCr
Next
MsgBox msg,0,"Total Users: " & x
usersTextBox.focus()
Else
MsgBox "No Users Entered",0,"Total Users: " & x
usersTextBox.focus()
End If
End Sub
'--------------------------------------------|
'Starts HTA over
'-------------------------------------------------------
Sub RunScriptHTARefresh
Location.Reload(True)
End Sub
'--------------------------------------------|
</script>
<body>
<input id=usersTextBox type="text" maxlength="29"
size="30">
<a
style="position:absolute;right:70;font:bold 1em arial;">
Users Added:   <span id="DataArea1"></span>
</a><br><hr>
<input id=addUsers type="button" value="Add User"
onClick="addUser(usersTextBox)"><br><hr>
<input id=showAllUsers type="button"
value="Show All Users"
onClick="showUsers()"><br><hr>
<input id=refresh type="button" value="Refresh"
onClick="RunScriptHTARefresh"><p>
<a
style="font-family:arial;font-weight:bold;color=red;">
Warning: Hitting Refresh button<br>
clears everything and starts over.
</body>
</html>