Two forms

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

    Two forms

    *** This is the first form i called it Form1?******
    *************** *************** *************** *************

    [CODE=vbnet]Imports System.Xml
    Imports System.IO
    Public Class Form1
    Inherits System.Windows. Forms.Form

    Private Sub btnFile_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles lodbtn.Click

    Dim ofd As OpenFileDialog = New OpenFileDialog
    Dim result As DialogResult = ofd.ShowDialog( )
    If result = DialogResult.Ca ncel Then
    Return
    End If

    Dim document As XmlDocument = New XmlDocument
    document.Load(o fd.FileName)

    Dim reader As XmlNodeReader = New XmlNodeReader(d ocument)
    MsgBox("The File is loaded successfully!")

    lblLoad.Text = (System.IO.Path .GetFullPath(of d.FileName))

    Disbtn.Enabled = True



    End Sub

    Private Sub Displaybtn_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Disbtn.Click
    Dim f As CourseDisplay
    f = New CourseDisplay
    f.Show()
    End Sub


    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

    End Sub[/CODE]

    ********* This is the second form i called it CourseDisplay.v b***********
    *************** *************** *************** *************** *************** ******

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

    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
    End While


    For i = 0 To Student.GetUppe rBound(0)
    sum += Convert.ToInt32 (Student(i))
    Next

    Label4.Text = studnetcount

    End Sub

    Private Sub clobtn_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles clobtn.Click

    Me.Close()

    End Sub
    End Class
    [/code]
    that what i did

    *********** the problem is how can i leave it to read the studnent

    or how i can do this ( that i have to do it )

    tempStr is a stirng variable
    studentCount is an integer variable
    studentCount =0
    WHILE there are more tags

    if tag is "courseID"
    read contents and display on form
    END IF

    if tag is " courseName"
    read contents and display on form
    END IF
    if tag is "studnet"
    tempStr = " "
    Skip to next tag
    we are now on studnetID
    read contents of tag , add to tempStr, advance

    we are now on studnetName
    read contents of tag , add to tempStr, advance

    we are now on porgram
    read contents of tag , add to tempStr, advance

    Display tempStr on form
    Add 1 to studnentCount
    Last edited by debasisdas; Oct 15 '07, 11:41 AM. Reason: Formatted using code tags.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET Forum.

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      Please give more information about your problem or error you are receiving. What are you trying to do? Thanks.

      Comment

      • qatarya3sal
        New Member
        • Oct 2007
        • 11

        #4
        Originally posted by kenobewan
        Please give more information about your problem or error you are receiving. What are you trying to do? Thanks.
        I don't have error but i don't know how to do some steps .. the last one

        please help me

        *********** the problem is how can i leave it to read the studnent

        or how i can do this ( that i have to do it )

        tempStr is a stirng variable
        studentCount is an integer variable
        studentCount =0
        WHILE there are more tags

        if tag is "courseID"
        read contents and display on form
        END IF

        if tag is " courseName"
        read contents and display on form
        END IF
        if tag is "studnet"
        tempStr = " "
        Skip to next tag
        we are now on studnetID
        read contents of tag , add to tempStr, advance

        we are now on studnetName
        read contents of tag , add to tempStr, advance

        we are now on porgram
        read contents of tag , add to tempStr, advance

        Display tempStr on form
        Add 1 to studnentCount

        --------------------------------------------------------------------------------

        Comment

        • qatarya3sal
          New Member
          • Oct 2007
          • 11

          #5
          :( nobady can help me

          Comment

          • Shashi Sadasivan
            Recognized Expert Top Contributor
            • Aug 2007
            • 1435

            #6
            What are you trying to do?

            Comment

            • qatarya3sal
              New Member
              • Oct 2007
              • 11

              #7
              Originally posted by Shashi Sadasivan
              What are you trying to do?
              what i try to do

              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

              before i end the while i have to do this steps

              tempStr is a stirng variable
              studentCount is an integer variable
              studentCount =0
              WHILE there are more tags

              if tag is "courseID"
              read contents and display on form
              END IF

              if tag is " courseName"
              read contents and display on form
              END IF
              if tag is "studnet"
              tempStr = " "
              Skip to next tag
              we are now on studnetID
              read contents of tag , add to tempStr, advance

              we are now on studnetName
              read contents of tag , add to tempStr, advance

              we are now on porgram
              read contents of tag , add to tempStr, advance

              Display tempStr on form
              Add 1 to studnentCount

              after that i end while

              i want to read every studnet id , name and program

              now i clear or not

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Originally posted by qatarya3sal
                what i try to do

                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

                before i end the while i have to do this steps

                tempStr is a stirng variable
                studentCount is an integer variable
                studentCount =0
                WHILE there are more tags

                if tag is "courseID"
                read contents and display on form
                END IF

                if tag is " courseName"
                read contents and display on form
                END IF
                if tag is "studnet"
                tempStr = " "
                Skip to next tag
                we are now on studnetID
                read contents of tag , add to tempStr, advance

                we are now on studnetName
                read contents of tag , add to tempStr, advance

                we are now on porgram
                read contents of tag , add to tempStr, advance

                Display tempStr on form
                Add 1 to studnentCount

                after that i end while

                i want to read every studnet id , name and program

                now i clear or not

                Have you tried to just......write the code for this?

                It appears that you know what you want to do.
                Have you tried to Do It?

                Comment

                • qatarya3sal
                  New Member
                  • Oct 2007
                  • 11

                  #9
                  Originally posted by Frinavale
                  Have you tried to just......write the code for this?

                  It appears that you know what you want to do.
                  Have you tried to Do It?

                  yes i tried to do it but i don't now how to do it can you help me

                  Comment

                  • qatarya3sal
                    New Member
                    • Oct 2007
                    • 11

                    #10
                    My questions is hard or what nobady can help me or what

                    Comment

                    • Shashi Sadasivan
                      Recognized Expert Top Contributor
                      • Aug 2007
                      • 1435

                      #11
                      For starters,
                      Its difficult to follow your code.
                      I would rather get back to work..than take some time off it and go through your code (There is no valid commenting, nor have you used the code tags)

                      Secondly, You do seem to have coded all what you want, but are failing to explain what you want to do.

                      So think about what you want (dont expect someone over here to write code for you)
                      We will be happy with fixing up your code.

                      Comment

                      • Frinavale
                        Recognized Expert Expert
                        • Oct 2006
                        • 9749

                        #12
                        Originally posted by qatarya3sal
                        My questions is hard or what nobady can help me or what
                        First of all, It is difficult for the experts to answer questions when there is not enough details provided to understand the problem.

                        Secondly, to me it feels as if you are asking the us to do a homework assignment for you. It seems as if you have had some code given to you and you are to add onto the assignment or programming. It is also a rule here that members of this fourm not provide full solutions to homework problems.

                        The experts on this forum are more than happy to help you with a specific problem that you are facing.

                        Please attempt to solve the problem first and then post your question about specific problems that you are encountering.

                        Comment

                        • qatarya3sal
                          New Member
                          • Oct 2007
                          • 11

                          #13
                          [code=vbnet]
                          Dim tempStr as string' (tempStr is a stirng variable it)
                          Dim studentCount as integer = 0'(studentCount is an integer variable)

                          While reader.Read() '((WHILE there are more tags))

                          '((if tag is "courseID"
                          'read contents and display on form
                          'END IF) )

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

                          '((if tag is " courseName"
                          'read contents and display on form
                          'END IF))

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

                          '((((if tag is "studnet"
                          'tempStr = " "
                          'Skip to next tag
                          'we are now on studnetID
                          'read contents of tag , add to tempStr, advance

                          'we are now on studnetName
                          'read contents of tag , add to tempStr, advance

                          'we are now on porgram
                          'read contents of tag , add to tempStr, advance))))


                          If reader.Name = "student" And reader.NodeType = XmlNodeType.Ele ment Then
                          tempStr = ""

                          If reader.Name = "studentID" Then
                          ListBox1.Text = tempStr + reader.ReadElem entString()
                          End If
                          If reader.Name = "studentNam e" Then
                          ListBox1.Text = tempStr + reader.ReadElem entString()
                          End If
                          If reader.Name = "program" Then
                          ListBox1.Text = tempStr + reader.ReadElem entString()
                          End If
                          End If
                          ReDim Preserve Student(index)
                          Student(index) = reader.ReadElem entString()
                          index += 1
                          studnetcount += 1
                          End If


                          For i = 0 To Student.GetUppe rBound(0)
                          sum += Convert.ToInt32 (Student(i))
                          Next

                          Label4.Text = studnetcount

                          End Sub
                          End While[/code]

                          when i did that nothing in the screen i don't know what problem it cant read the student id ,name and porgram

                          this is my work now do understand or no
                          Display tempStr on form
                          Add 1 to studnentCount
                          Last edited by Frinavale; Oct 18 '07, 01:12 PM. Reason: Added [code] tags to make more legible

                          Comment

                          • Frinavale
                            Recognized Expert Expert
                            • Oct 2006
                            • 9749

                            #14
                            I'm not sure what type of object your reader variable is.
                            It's the only one that doesn't appear to be defined in this code.

                            In the future, when posting code, please use [code] tags.
                            An example of posting VB.NET code would be:
                            [code=vb net]
                            'My VB.NET Code pasted here
                            [/code]

                            Comment

                            • qatarya3sal
                              New Member
                              • Oct 2007
                              • 11

                              #15
                              Originally posted by Frinavale
                              I'm not sure what type of object your reader variable is.
                              It's the only one that doesn't appear to be defined in this code.

                              In the future, when posting code, please use
                              Code:
                               tags.
                              An example of posting VB.NET code would be:
                              [code=vbnet]
                              'My VB.NET Code pasted here
                              reader to read

                              i want to know if anybody can understand what i want and help me or no

                              Comment

                              Working...