I want to create a toolbar button, which controls toolbar is on MDIForm and I make a function in the Module.
My code like this:
VB.NET Code:
Sub AddToolbarButtons() 'MDI Main form Dim fMain As MDIMain 'create toolbar buttons With fMain.TBar .Buttons.Clear() .Buttons.Add(setButton("Add", 1)) .Buttons.Add(setButton("Modify", 2)) .Buttons.Add(setButton("Delete", 3)) .Buttons.Add(setButton("Preview", 4)) .Buttons.Add(setButton("Refresh", 5)) .Buttons.Add(setButton("Close", 6)) End With Function setButton(ByVal txt, ByVal imgIdx) As ToolBarButton Dim btn As New ToolBarButton btn.Text = txt btn.ImageIndex = imgIdx Return btn End Function
and I get an error message like this:
atCode:An unhandled exception of type 'System.NullReferenceException' occurred in POSClient.exe Additional information: Object reference not set to an instance of an object.
VB.NET Code:
'create toolbar buttons With fMain.TBar
what's the solution ?
thank you![]()




Reply With Quote