Click here to Skip to main content
15,910,661 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to conver Exhadecimal to Text ? Pin
Eddy Vluggen12-Feb-10 0:02
professionalEddy Vluggen12-Feb-10 0:02 
GeneralRe: How to conver Exhadecimal to Text ? Pin
Golden Jing14-Feb-10 22:15
Golden Jing14-Feb-10 22:15 
QuestionFile Transfer from PPC Pin
Dominick Marciano10-Feb-10 9:28
professionalDominick Marciano10-Feb-10 9:28 
Questionclient in same lan help me Pin
Cosby10-Feb-10 5:26
Cosby10-Feb-10 5:26 
AnswerRe: client in same lan help me Pin
Eddy Vluggen10-Feb-10 21:49
professionalEddy Vluggen10-Feb-10 21:49 
GeneralRe: client in same lan help me Pin
Cosby10-Feb-10 21:54
Cosby10-Feb-10 21:54 
QuestionWake On Lan HELP Pin
Cosby10-Feb-10 5:25
Cosby10-Feb-10 5:25 
QuestionObject null reference exception Pin
ademsandeepreddy10-Feb-10 2:48
ademsandeepreddy10-Feb-10 2:48 
write know i am gettin null reference exception due to followin code
Imports System.Xml
Imports System.IO


Public Class TreeView
Dim xNode As XmlNode
Private Sub btnOpenXml_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenXml.Click
populateTreeview()
End Sub
Private Function SelectTextFile() As String
Dim fDialog As New OpenFileDialog()
fDialog.Filter = "xml files (*.xml)|*.xml"
fDialog.InitialDirectory = "~\Desktop"
Return If((fDialog.ShowDialog() = DialogResult.OK), fDialog.FileName, Nothing)
End Function
Private Sub populateTreeview()
Try

'Just a good practice -- change the cursor to a
'wait cursor while the nodes populate
Me.Cursor = Cursors.WaitCursor
'First, we'll load the Xml document
Dim xDoc As New XmlDocument()
xDoc.Load(SelectTextFile())
'Now, clear out the treeview,
'and add the first (root) node
tvXmlTree.Nodes.Clear()
tvXmlTree.Nodes.Add(New TreeNode(xDoc.DocumentElement.Name))
Dim tNode As New TreeNode()
tNode = DirectCast(tvXmlTree.Nodes(0), TreeNode)
'We make a call to addTreeNode,
'where we'll add all of our nodes
addTreeNode(xDoc.DocumentElement, tNode)
'Expand the treeview to show all nodes
tvXmlTree.CollapseAll()
Catch xExc As XmlException
'Exception is thrown is there is an error in the Xml
MessageBox.Show(xExc.Message)
Catch ex As Exception
'General exception
MessageBox.Show(ex.Message)
Finally
'Change the cursor back
Me.Cursor = Cursors.[Default]
End Try

End Sub



Private Sub addTreeNode(ByVal xmlNode As XmlNode, ByVal treeNode As TreeNode)

Dim tNode As TreeNode
Dim xNodeList As XmlNodeList
If xmlNode.HasChildNodes Then
'The current node has children
xNodeList = xmlNode.ChildNodes
For x As Integer = 0 To xNodeList.Count - 1
'Loop through the child nodes
xNode = xmlNode.ChildNodes(x)
treeNode.Nodes.Add(New TreeNode(xNode.Name))
tNode = treeNode.Nodes(x)
addTreeNode(xNode, tNode)
Next
Else
'No children, so add the outer xml (trimming off whitespace)
'treeNode.Text = xmlNode.OuterXml.Trim()
' treeNode.Text = xmlNode.LocalName.Trim()
End If
End Sub


Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
tvXmlTree.Refresh()
End Sub


Private Sub tvXmlTree_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvXmlTree.AfterSelect
'xNode = DirectCast(tvXmlTree.SelectedNode.Tag, XmlNode)
'Me.txtContent.Text = xNode.InnerXml
End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub btnDeleteNode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteNode.Click
tvXmlTree.SelectedNode.Remove()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

End Sub


Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtContent.Text = String.Empty
txtXml.Text = String.Empty
End Sub
End Class


the above is my code
in this block i am getting object null reference exception


Private Sub tvXmlTree_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvXmlTree.AfterSelect
'xNode = DirectCast(tvXmlTree.SelectedNode.Tag, XmlNode)
'Me.txtContent.Text = xNode.InnerXml
End Sub

i am unable to figure out.can anybody share u r views regarding this issue hw to clarify this

Thanks & Regards

SANDEEP ADEM
hi

AnswerRe: Object null reference exception Pin
dan!sh 10-Feb-10 2:51
professional dan!sh 10-Feb-10 2:51 
GeneralObject null reference exception Pin
ademsandeepreddy10-Feb-10 3:08
ademsandeepreddy10-Feb-10 3:08 
GeneralRe: Object null reference exception Pin
dan!sh 10-Feb-10 3:53
professional dan!sh 10-Feb-10 3:53 
GeneralRe: Object null reference exception Pin
William Winner10-Feb-10 6:03
William Winner10-Feb-10 6:03 
GeneralRe: Object null reference exception Pin
ademsandeepreddy10-Feb-10 6:48
ademsandeepreddy10-Feb-10 6:48 
GeneralRe: Object null reference exception Pin
rhuiden10-Feb-10 6:25
rhuiden10-Feb-10 6:25 
GeneralRe: Object null reference exception Pin
William Winner10-Feb-10 6:59
William Winner10-Feb-10 6:59 
GeneralRe: Object null reference exception Pin
rhuiden10-Feb-10 7:21
rhuiden10-Feb-10 7:21 
RantRe: Object null reference exception Pin
William Winner10-Feb-10 6:17
William Winner10-Feb-10 6:17 
QuestionFilter between date Pin
akosidandan9-Feb-10 21:09
akosidandan9-Feb-10 21:09 
AnswerRe: Filter between date Pin
thatraja9-Feb-10 22:07
professionalthatraja9-Feb-10 22:07 
GeneralRe: Filter between date Pin
akosidandan10-Feb-10 2:12
akosidandan10-Feb-10 2:12 
AnswerRe: Filter between date Pin
thatraja10-Feb-10 2:16
professionalthatraja10-Feb-10 2:16 
AnswerRe: Filter between date Pin
εїзεїзεїз10-Feb-10 1:20
εїзεїзεїз10-Feb-10 1:20 
QuestionHow to add app.config for Visual Basic Application Pin
ramdili9-Feb-10 4:42
ramdili9-Feb-10 4:42 
AnswerRe: How to add app.config for Visual Basic Application Pin
Dave Kreskowiak9-Feb-10 5:38
mveDave Kreskowiak9-Feb-10 5:38 
AnswerRe: How to add app.config for Visual Basic Application Pin
εїзεїзεїз10-Feb-10 1:28
εїзεїзεїз10-Feb-10 1:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.