Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21162

How can I separate items in a listbox that were put there using an array?

$
0
0
Hi there folks, I have a listbox called Studentlist. It has 4 different items put there in an array like this.

VB Code:
  1. Option Explicit
  2.  
  3. Private Students As Object
  4. Students.AddNew Array("Name", "Points", "Avatar", "Birthday"), Array(EditRosterV3.StudentNameTXT(0).Text, EditRosterV3.PointCountLBL(0).Caption, EditRosterV3.StudentAvatarPathTXT(0).Text, EditRosterV3.StudentBdayLBL(0).Caption)

The listbox is set up like this..

Set Students = CreateObject("ADODB.Recordset")
Students.Fields.Append "Name", 202, 4000 '202=adVarWChar
Students.Fields.Append "Points", 3 '3=adInteger
Students.Fields.Append "Avatar", 202, 4000 '202=adVarWChar
Students.Fields.Append "Birthday", 202, 4000 '202=adVarWChar


And items are put into the listbox like this...

VB Code:
  1. Private Sub FillList(Optional ByVal OrderByClause As String)
  2. Dim i As Long
  3.   Students.Sort = OrderByClause
  4.   StudentList.Clear
  5.   For i = 1 To Students.RecordCount
  6.     Students.AbsolutePosition = i
  7.     StudentList.AddItem Students!Points & vbTab & Students!Name & vbTab & Students!Birthday & vbTab & Students!Avatar
  8.   Next i
  9. End Sub


Now the reason why we do that is so we can organize the student names alphabetically, and keep track of whos birthday, points, avatar are whoms, so when the names are reordered, the other things stay with the student.

Now my problem is I am trying to copy the items back into their original textboxes and label captions, these are the same ones they came from, so again they stay in order with the student.

I can do it by going StudentNameTXT(0).text = Students!Name, but it will only give me the last item entered at the bottom of the list, I would like to have it go to the top.

Is there some trick I am missing here? Thanks!!!!

Viewing all articles
Browse latest Browse all 21162


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>