Please I need your help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qatarya3sal
    New Member
    • Oct 2007
    • 11

    Please I need your help

    [code=vbnet]Imports System.IO
    Public Class CourseDisplay
    Inherits System.Windows. Forms.Form

    Dim studnetcount As Integer = 0
    Dim tempStr As String = ""
    Dim studentID As String
    Dim studentName As String
    Dim program As String
    Dim Students As Student() = New Student() {}
    Dim StudentString As String

    Private Sub Display_Load(By Val sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load


    Dim document As XmlDocument = New XmlDocument
    document.Load(" CP2830.xml")

    Dim reader As XmlNodeReader = New XmlNodeReader(d ocument)

    While reader.Read()

    If reader.Name = "courseID" Then
    Label1.Text = reader.ReadElem entString()
    End If

    If reader.Name = "courseName " Then
    Label2.Text = reader.ReadElem entString()
    End If

    If (reader.Name = "student") Then
    reader.Read()
    studentID = reader.ReadElem entString()
    studentName = reader.ReadElem entString()
    program = reader.ReadElem entString()
    studnetcount += 1

    End If


    End While

    StudentString = (studentID + studentName + program)
    ListBox1.Items. Add(StudentStri ng)
    Label4.Text = studnetcount

    End Sub

    End Class[/code]

    The problem is it read only one student but i have five student i don't where is the problem
    Last edited by debasisdas; Oct 24 '07, 09:19 AM. Reason: Formatted using code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET Forum.

    Comment

    • shweta123
      Recognized Expert Contributor
      • Nov 2006
      • 692

      #3
      Hi,

      If you put your statements which are written outside the while loop, into the loop, you may get the required result you want.

      e.g. try this code

      If (reader.Name = "student") Then
      reader.Read()
      studentID = reader.ReadElem entString()
      studentName = reader.ReadElem entString()
      program = reader.ReadElem entString()
      StudentString = (studentID + studentName + program)
      ListBox1.Items. Add(StudentStri ng)
      Label4.Text = studnetcount
      end if

      Comment

      • radcaesar
        Recognized Expert Contributor
        • Sep 2006
        • 759

        #4
        StudentString = (studentID + studentName + program)
        ListBox1.Items. Add(StudentStri ng)


        Move the above two lines inside the while loop.

        Comment

        Working...