Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB.NET
Imports System.Xml
Imports System.IO

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim xmldoc As New XmlDataDocument()
        Dim xmlnode As XmlNodeList
        Dim i As Integer
        Dim str As String
        Dim fs As New FileStream("Book1.xml", FileMode.Open, FileAccess.Read)
        xmldoc.Load(fs)
        xmlnode = xmldoc.GetElementsByTagName("Book")
        For i = 0 To xmlnode.Count - 1
            xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
            str = xmlnode(i).ChildNodes.Item(0).InnerText.Trim() & " | " & xmlnode(i).ChildNodes.Item(1).InnerText.Trim() & " | " & xmlnode(i).ChildNodes.Item(2).InnerText.Trim()
            MsgBox(str)
        Next
        Me.DataGridView1.Rows.Add(TextBox1.Text, TextBox2.Text, ComboBox1.Text, TextBox3.Text)
    End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        XmlNodeList -= 1

        If XmlNodeList < 0 Then
            XmlNodeList = 0
        End If
        ShowData(XmlNodeList

    End Sub
End Class


What I have tried:

VB.NET
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        XmlNodeList -= 1

        If XmlNodeList < 0 Then
            XmlNodeList = 0
        End If
        ShowData(XmlNodeList

    End Sub
End Class
Posted
Updated 8-Feb-21 21:02pm
v2

You are going to have to explain much more clearly what you are trying to do and what problems you are having doing it before we can even start to help you solve the problem: just asking a question like "How do I to navigate record (next, previous, first & last)" requiring four methods, and just providing "What I have tried" code for one method that won't even compile doesn't help you at all.

And frankly, you need to learn some coding style basics before you get any further.
First off: Stop using Visual Studio default names for everything - you may remember that "TextBox8" is the mobile number today, but when you have to modify it in three weeks time, will you then? Use descriptive names - "tbMobileNo" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbMobile" in three keystrokes, where "TextBox8" takes thinking about and 8 keystrokes...
Six buttons or more, all called "Button1" to "Button6", with default names for a bunch of TextBoxes as well just means your code is unreadable without looking at the design to work out what the buttons should do! And that means errors are easy to make and hard to spot.

Stop using MsgBox: it's well any truly out of date. It died with VB6, back in 2001 when .NET was released, and exists only so VB6 code can run. Just. Use MessageBox.Show instead.

Now sit down, think about your task, and what you have to do - and remember that we can't see your screen, can't access your HDD, don't get your homework assignment from your teacher, and can't read your mind. We only get exactly what you type: so if you want help, explain where you are stuck, what you have tried, and what happened when you did. Tell us what help you need - and remember that homework is there to help you learn, so we won't just give you the code ready to hand in as your own work!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900