Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Dynamic listbox not working properly

Avatar of piattnd
piattnd asked on
HTMLVB Script
9 Comments1 Solution772 ViewsLast Modified:
Experts,

I was previously assisted on this topic, however I've encountered another poblem.

My script pulls a query within AD for a list of users.  It then sorts that list of users alphabetically and puts the sorted items back into the original dictionary.

I am able to post the items to the GUI, but when I begin typing out the name of a person I want to select, the script is removing the incorrect entries.

For example, if I type "Fr", anything that doesn't have (or start with) "Fr" should be removed, and the others should remain.

I've posted my code, any help would be appreciated.
Set objRecordSet = objCommand.Execute
 
	objRecordSet.MoveFirst
 
	Do Until objRecordSet.EOF
 
		'msgbox objRecordSet.Fields("givenName").Value & " " & objRecordSet.Fields("sn").Value
 
		strUserAccount = UCase(objRecordSet.Fields("sAMAccountName").Value)
		strUserEntry = UCase(objRecordSet.Fields("givenName").Value) & " " & UCase(objRecordSet.Fields("sn").Value)
		strUserMail = objRecordSet.Fields("mail").Value
		
		If strUserAccount = "null" OR strUserEntry = "null" OR strUserMail = null then
			'skip record, do nothing
		Else
			dicUserNameList.Add strUserEntry,strUserAccount
		End If
 
		ObjRecordSet.MoveNext
 
	Loop
 
	msgbox "Entries created"
	Set objDictSorted = SortDict(dicUserNameList)
	window.setTimeout "BuildList()",200
End Sub
 
Function SortDict(ByVal objDict)
 
 Dim i, j, temp
 
 For Each i In objDict
  For Each j In objDict
   If(objDict.Item(i) <= objDict.Item(j)) Then
    temp = objDict.Item(i)
    objDict.Item(i) = objDict.Item(j)
    objDict.Item(j) = temp
   End If
  Next
 Next
 
 'For Each i In objDict
  'msgbox objDict.Item(i)
 'Next
 
 Set SortDict = dicUserNameList
 
End Function
 
 
Sub BuildList
 
	For Each strUser in dicUserNameList
			'msgbox strUser & " " & strUserEmail
			Set objOption = Document.createElement("OPTION")
			objOption.Text = dicUserNameList.Item(strUser)
			objOption.Value = dicUserNameList.Item(strUser)
			'msgbox objOption.Text & " " & objOption.Value
			UserNames.Add(objOption)
	Next
 
End Sub
 
Sub CheckValue
 
	msgbox UserNames.Value
 
End Sub
 
Sub CheckKey
	Set objOptions = UserNames.Options
		
	For Each strOption in objOptions
		strOption.RemoveNode
	Next
	
	If EnterName.Value = "" then
		
		For Each strUser in dicUserNameList
			'msgbox strUser & " " & strUserEmail
			Set objOption = Document.createElement("OPTION")
			objOption.Text = dicUserNameList.Item(strUser)
			objOption.Value = dicUserNameList.Item(strUser)			
			'msgbox objOption.Text & " " & objOption.Value
			UserNames.Add(objOption)
		Next
	
	Else 
		
		'For Each strUser in dicUserNameList
		For Each strUser in objDict
		
		strEntryLength = len(EnterName.Value)
		msgbox left(strUser,strEntryLength)
			If left(strUser,strEntryLength) = Ucase(EnterName.Value) then
				Set objOption = Document.createElement("OPTION")
				objOption.Text = dicUserNameList.Item(strUser)
				objOption.Value = dicUserNameList.Item(strUser)
				UserNames.Add(objOption)
			Else
				'Nothing, doesn't match.
			End If
		Next		
	End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of rejoinder
rejoinderFlag of Canada imageManager, IT
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answers