Looping problems

Need to display the Gold, Silver, And Bronze members in a list box fro

Page 1 of 1

3 Replies - 996 Views - Last Post: 24 January 2010 - 10:38 AM Rate Topic: -----

#1 alishachap  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-January 10

Looping problems

Posted 24 January 2010 - 10:12 AM

Need to display the Gold, Silver, And Bronze members in a list box from a TXT file. Have problems isolation each group. When I run the program all of the name in the TXT file come into the list box.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
		Dim strMembers As String, objStreamReader As System.IO.StreamReader
		'update members to memberslistbox
		If System.IO.File.Exists("NEWMEMBERS.TXT") = True Then
			objStreamReader = System.IO.File.OpenText("NEWMEMBERS.TXT")
			Me.lstNewMembers.Items.Clear()

			Do While objStreamReader.Peek <> -1
				strMembers = objStreamReader.ReadLine()
				Me.lstNewMembers.Items.Add(strMembers)
			Loop
			objStreamReader.Close()
			Me.lstNewMembers.SelectedIndex = 0
		End If
	End Sub
	'read file into stream reader
	'clear list
	'loop through each line of file
	'in loop readline
	'store contents of current line in variable
	'loop
	'read next line pass variable contents and currently read line into procedure with the group name
	'if group name = the contents just read in the file add the previously read variable into the list, else do nothing.

	Private Sub ShowMembers(ByVal group As String)
		'Diplays the results of the group members
		lstNewMembers.Items.Add("Silver Members")
		ShowMembers("Silver")
		lstNewMembers.Items.Add("gold Members")
		ShowMembers("Gold")
		lstNewMembers.Items.Add("Bronze Members")
		ShowMembers("Bronze")
	End Sub
End Class



Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Looping problems

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Looping problems

Posted 24 January 2010 - 10:23 AM

pls post your code in tags like so
:code:
ty for helping us helping you :)

This post has been edited by NoBrain: 24 January 2010 - 10:23 AM

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Looping problems

Posted 24 January 2010 - 10:26 AM

That is VB.NET code. not VB6.

Moved to VB.NET :)
Was This Post Helpful? 0
  • +
  • -

#4 alishachap  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-January 10

Re: Looping problems

Posted 24 January 2010 - 10:38 AM

Having problems with getting the isolated txt into the list box.
I need to take the txt ( gold,silver,and bronze members) and place them into a list box. I can get all of the members into the list box, but I only need the isolated groups. If the person is looking for gold members then only gold member need to be in the list box.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
		Dim strMembers As String, objStreamReader As System.IO.StreamReader
		'update members to memberslistbox
		If System.IO.File.Exists("NEWMEMBERS.TXT") = True Then
			objStreamReader = System.IO.File.OpenText("NEWMEMBERS.TXT")
			Me.lstNewMembers.Items.Clear()

			Do While objStreamReader.Peek <> -1
				strMembers = objStreamReader.ReadLine()
				Me.lstNewMembers.Items.Add(strMembers)
			Loop
			objStreamReader.Close()
			Me.lstNewMembers.SelectedIndex = 0
		End If
	End Sub 

	'read file into stream reader
	'clear list
	'loop through each line of file
	'in loop readline
	'store contents of current line in variable
	'loop
	'read next line pass variable contents and currently read line into procedure with the group name
	'if group name = the contents just read in the file add the previously read variable into the list, else do nothing.

  
  Private Sub ShowMembers(ByVal group As String)
		'Diplays the results of the group members
		lstNewMembers.Items.Add("Silver Members")
		ShowMembers("Silver")
		lstNewMembers.Items.Add("gold Members")
		ShowMembers("Gold")
		lstNewMembers.Items.Add("Bronze Members")
		ShowMembers("Bronze")
	End Sub
End Class



EDIT: Code tags fixed :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1