Home All Groups Group Topic Archive Search About

Problem calling a Sub in another form

Author
21 Sep 2006 10:49 AM
vitorjol
Hello.

I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
form2, i get the error "object reference not set to an instance of an object"
!
What can i do to solve the problem?

Thanks

Author
21 Sep 2006 12:25 PM
rowe_newsgroups
Please post the code that calls the sub.

Thanks,

Seth Rowe

vitorjol wrote:
Show quoteHide quote
> Hello.
>
> I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> form2, i get the error "object reference not set to an instance of an object"
> !
> What can i do to solve the problem?
>
> Thanks
Author
21 Sep 2006 1:18 PM
vitorjol
Here is the code:

' the code in form2
Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
DataGridView1.RowHeaderMouseClick
        dim exitvar as Integer
        exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
        Dim ff As New Form1
        ff.BringToFront()
        ff.soumavez(exitvar) ' this is the call to the sub in Form1
    End Sub

Show quoteHide quote
"rowe_newsgroups" wrote:

> Please post the code that calls the sub.
>
> Thanks,
>
> Seth Rowe
>
> vitorjol wrote:
> > Hello.
> >
> > I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> > form2, i get the error "object reference not set to an instance of an object"
> > !
> > What can i do to solve the problem?
> >
> > Thanks
>
>
Author
21 Sep 2006 4:06 PM
rowe_newsgroups
Looks like it should work, when you step through the code where does
the exception occur?  If the error occurs in somewhere other than this
sub please post that code too. Also what does "soumavez" mean?

Thanks,

Seth Rowe


vitorjol wrote:
Show quoteHide quote
> Here is the code:
>
> ' the code in form2
> Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
> e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
> DataGridView1.RowHeaderMouseClick
>         dim exitvar as Integer
>         exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
>         Dim ff As New Form1
>         ff.BringToFront()
>         ff.soumavez(exitvar) ' this is the call to the sub in Form1
>     End Sub
>
> "rowe_newsgroups" wrote:
>
> > Please post the code that calls the sub.
> >
> > Thanks,
> >
> > Seth Rowe
> >
> > vitorjol wrote:
> > > Hello.
> > >
> > > I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> > > form2, i get the error "object reference not set to an instance of an object"
> > > !
> > > What can i do to solve the problem?
> > >
> > > Thanks
> >
> >
Author
21 Sep 2006 4:24 PM
vitorjol
ok....the name "soumavez" its a name that i called to the Sub...End Sub.

i put here the code of Sub(its about the Mapguide ActiveX to show a map in
VB). I'll send there to Sub in the other form the id of a polygon on the map,
and then the Sub localize the polygon and zoom the place!!!

Code of the Sub "soumavez" in the Form1:

Public Sub soumavez(ByVal varin As Integer)
' --->"varin" its the var that i send from Form2!!!
' --->"mgmap" its the name of the control (mapguide activex)
        Try
            Dim pubmapsel As MGMapControl.MGSelection
            Dim pubvar2 As MGMapControl.MGMapLayer
            Dim pubmapobjectos As MGMapControl.MGCollection
            Dim pubmapobj As MGMapControl.MGMapObject
            pubmapsel = mgmap.getSelection()
            pubvar2 = mgmap.getMapLayer("SIG")
            pubmapobjectos = mgmap.createObject("MGCollection")
            pubmapobj = pubvar2.getMapObject(varin)
            pubmapobjectos.add(pubmapobj)
            pubmapsel.addObjectsEx(pubmapobjectos, False)
            mgmap.zoomSelected()
            mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
            mgmap.refresh()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
MessageBoxIcon.Error)
        End Try
End Sub


Show quoteHide quote
"rowe_newsgroups" wrote:

> Looks like it should work, when you step through the code where does
> the exception occur?  If the error occurs in somewhere other than this
> sub please post that code too. Also what does "soumavez" mean?
>
> Thanks,
>
> Seth Rowe
>
>
> vitorjol wrote:
> > Here is the code:
> >
> > ' the code in form2
> > Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
> > e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
> > DataGridView1.RowHeaderMouseClick
> >         dim exitvar as Integer
> >         exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
> >         Dim ff As New Form1
> >         ff.BringToFront()
> >         ff.soumavez(exitvar) ' this is the call to the sub in Form1
> >     End Sub
> >
> > "rowe_newsgroups" wrote:
> >
> > > Please post the code that calls the sub.
> > >
> > > Thanks,
> > >
> > > Seth Rowe
> > >
> > > vitorjol wrote:
> > > > Hello.
> > > >
> > > > I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> > > > form2, i get the error "object reference not set to an instance of an object"
> > > > !
> > > > What can i do to solve the problem?
> > > >
> > > > Thanks
> > >
> > >
>
>
Author
21 Sep 2006 4:57 PM
rowe_newsgroups
> ok....the name "soumavez" its a name that i called to the Sub...End Sub.

It looked like a foreign langauge to me (is it?), so I was just making
sure it was a protected keyword in a foreign language edition of visual
studio.

Anyways, I have to apologize - my "visual" debugging skills must be
lacking today, as I still don't see anything obviously wrong. Which
line of the code raises the exception?

Thanks,

Seth Rowe


vitorjol wrote:

Show quoteHide quote
>
> i put here the code of Sub(its about the Mapguide ActiveX to show a map in
> VB). I'll send there to Sub in the other form the id of a polygon on the map,
> and then the Sub localize the polygon and zoom the place!!!
>
> Code of the Sub "soumavez" in the Form1:
>
> Public Sub soumavez(ByVal varin As Integer)
> ' --->"varin" its the var that i send from Form2!!!
> ' --->"mgmap" its the name of the control (mapguide activex)
>         Try
>             Dim pubmapsel As MGMapControl.MGSelection
>             Dim pubvar2 As MGMapControl.MGMapLayer
>             Dim pubmapobjectos As MGMapControl.MGCollection
>             Dim pubmapobj As MGMapControl.MGMapObject
>             pubmapsel = mgmap.getSelection()
>             pubvar2 = mgmap.getMapLayer("SIG")
>             pubmapobjectos = mgmap.createObject("MGCollection")
>             pubmapobj = pubvar2.getMapObject(varin)
>             pubmapobjectos.add(pubmapobj)
>             pubmapsel.addObjectsEx(pubmapobjectos, False)
>             mgmap.zoomSelected()
>             mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
>             mgmap.refresh()
>         Catch ex As Exception
>             MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
> MessageBoxIcon.Error)
>         End Try
>  End Sub
>
>
> "rowe_newsgroups" wrote:
>
> > Looks like it should work, when you step through the code where does
> > the exception occur?  If the error occurs in somewhere other than this
> > sub please post that code too. Also what does "soumavez" mean?
> >
> > Thanks,
> >
> > Seth Rowe
> >
> >
> > vitorjol wrote:
> > > Here is the code:
> > >
> > > ' the code in form2
> > > Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
> > > e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
> > > DataGridView1.RowHeaderMouseClick
> > >         dim exitvar as Integer
> > >         exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
> > >         Dim ff As New Form1
> > >         ff.BringToFront()
> > >         ff.soumavez(exitvar) ' this is the call to the sub in Form1
> > >     End Sub
> > >
> > > "rowe_newsgroups" wrote:
> > >
> > > > Please post the code that calls the sub.
> > > >
> > > > Thanks,
> > > >
> > > > Seth Rowe
> > > >
> > > > vitorjol wrote:
> > > > > Hello.
> > > > >
> > > > > I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> > > > > form2, i get the error "object reference not set to an instance of an object"
> > > > > !
> > > > > What can i do to solve the problem?
> > > > >
> > > > > Thanks
> > > >
> > > >
> >
> >
Author
21 Sep 2006 5:44 PM
vitorjol
Yes....im portuguese....but I love America!!!!!

i forgot to tell U the line with the problem!!!Sorry

So, the problem "object reference not set to an instance of an object"
occurs in the line >>pubmapobj = pubvar2.getMapObject(varin)

Thanks


Show quoteHide quote
"rowe_newsgroups" wrote:

> > ok....the name "soumavez" its a name that i called to the Sub...End Sub.
>
> It looked like a foreign langauge to me (is it?), so I was just making
> sure it was a protected keyword in a foreign language edition of visual
> studio.
>
> Anyways, I have to apologize - my "visual" debugging skills must be
> lacking today, as I still don't see anything obviously wrong. Which
> line of the code raises the exception?
>
> Thanks,
>
> Seth Rowe
>
>
> vitorjol wrote:
>
> >
> > i put here the code of Sub(its about the Mapguide ActiveX to show a map in
> > VB). I'll send there to Sub in the other form the id of a polygon on the map,
> > and then the Sub localize the polygon and zoom the place!!!
> >
> > Code of the Sub "soumavez" in the Form1:
> >
> > Public Sub soumavez(ByVal varin As Integer)
> > ' --->"varin" its the var that i send from Form2!!!
> > ' --->"mgmap" its the name of the control (mapguide activex)
> >         Try
> >             Dim pubmapsel As MGMapControl.MGSelection
> >             Dim pubvar2 As MGMapControl.MGMapLayer
> >             Dim pubmapobjectos As MGMapControl.MGCollection
> >             Dim pubmapobj As MGMapControl.MGMapObject
> >             pubmapsel = mgmap.getSelection()
> >             pubvar2 = mgmap.getMapLayer("SIG")
> >             pubmapobjectos = mgmap.createObject("MGCollection")
> >             pubmapobj = pubvar2.getMapObject(varin)
> >             pubmapobjectos.add(pubmapobj)
> >             pubmapsel.addObjectsEx(pubmapobjectos, False)
> >             mgmap.zoomSelected()
> >             mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
> >             mgmap.refresh()
> >         Catch ex As Exception
> >             MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
> > MessageBoxIcon.Error)
> >         End Try
> >  End Sub
> >
> >
> > "rowe_newsgroups" wrote:
> >
> > > Looks like it should work, when you step through the code where does
> > > the exception occur?  If the error occurs in somewhere other than this
> > > sub please post that code too. Also what does "soumavez" mean?
> > >
> > > Thanks,
> > >
> > > Seth Rowe
> > >
> > >
> > > vitorjol wrote:
> > > > Here is the code:
> > > >
> > > > ' the code in form2
> > > > Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
> > > > e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
> > > > DataGridView1.RowHeaderMouseClick
> > > >         dim exitvar as Integer
> > > >         exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
> > > >         Dim ff As New Form1
> > > >         ff.BringToFront()
> > > >         ff.soumavez(exitvar) ' this is the call to the sub in Form1
> > > >     End Sub
> > > >
> > > > "rowe_newsgroups" wrote:
> > > >
> > > > > Please post the code that calls the sub.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Seth Rowe
> > > > >
> > > > > vitorjol wrote:
> > > > > > Hello.
> > > > > >
> > > > > > I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> > > > > > form2, i get the error "object reference not set to an instance of an object"
> > > > > > !
> > > > > > What can i do to solve the problem?
> > > > > >
> > > > > > Thanks
> > > > >
> > > > >
> > >
> > >
>
>
Author
21 Sep 2006 6:12 PM
rowe_newsgroups
Hmm. The "object reference not set to an instance of an object"
exception is raised when you try to use an object that doesn't exist
yet, like if you left out the New keyword. However, everything looks
alright to me. The only thing I would try (outside of praying that
someone else happens on this thread and sees what we're missing!) is to
change this line:

>pubmapobj = pubvar2.getMapObject(varin)

To this:

pubmapobj = MGMapControl.MGMapLayer.getMapObject(varin)

That will take the pubvar2 variable out of the equation. Note, you may
also try throwing  the "New" keyword into that line, I'm not sure if
you do or don't need it.

Hope that helps,

Seth Rowe

vitorjol wrote:
Show quoteHide quote
> Yes....im portuguese....but I love America!!!!!
>
> i forgot to tell U the line with the problem!!!Sorry
>
> So, the problem "object reference not set to an instance of an object"
> occurs in the line >>pubmapobj = pubvar2.getMapObject(varin)
>
> Thanks
>
>
> "rowe_newsgroups" wrote:
>
> > > ok....the name "soumavez" its a name that i called to the Sub...End Sub.
> >
> > It looked like a foreign langauge to me (is it?), so I was just making
> > sure it was a protected keyword in a foreign language edition of visual
> > studio.
> >
> > Anyways, I have to apologize - my "visual" debugging skills must be
> > lacking today, as I still don't see anything obviously wrong. Which
> > line of the code raises the exception?
> >
> > Thanks,
> >
> > Seth Rowe
> >
> >
> > vitorjol wrote:
> >
> > >
> > > i put here the code of Sub(its about the Mapguide ActiveX to show a map in
> > > VB). I'll send there to Sub in the other form the id of a polygon on the map,
> > > and then the Sub localize the polygon and zoom the place!!!
> > >
> > > Code of the Sub "soumavez" in the Form1:
> > >
> > > Public Sub soumavez(ByVal varin As Integer)
> > > ' --->"varin" its the var that i send from Form2!!!
> > > ' --->"mgmap" its the name of the control (mapguide activex)
> > >         Try
> > >             Dim pubmapsel As MGMapControl.MGSelection
> > >             Dim pubvar2 As MGMapControl.MGMapLayer
> > >             Dim pubmapobjectos As MGMapControl.MGCollection
> > >             Dim pubmapobj As MGMapControl.MGMapObject
> > >             pubmapsel = mgmap.getSelection()
> > >             pubvar2 = mgmap.getMapLayer("SIG")
> > >             pubmapobjectos = mgmap.createObject("MGCollection")
> > >             pubmapobj = pubvar2.getMapObject(varin)
> > >             pubmapobjectos.add(pubmapobj)
> > >             pubmapsel.addObjectsEx(pubmapobjectos, False)
> > >             mgmap.zoomSelected()
> > >             mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
> > >             mgmap.refresh()
> > >         Catch ex As Exception
> > >             MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
> > > MessageBoxIcon.Error)
> > >         End Try
> > >  End Sub
> > >
> > >
> > > "rowe_newsgroups" wrote:
> > >
> > > > Looks like it should work, when you step through the code where does
> > > > the exception occur?  If the error occurs in somewhere other than this
> > > > sub please post that code too. Also what does "soumavez" mean?
> > > >
> > > > Thanks,
> > > >
> > > > Seth Rowe
> > > >
> > > >
> > > > vitorjol wrote:
> > > > > Here is the code:
> > > > >
> > > > > ' the code in form2
> > > > > Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
> > > > > e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
> > > > > DataGridView1.RowHeaderMouseClick
> > > > >         dim exitvar as Integer
> > > > >         exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
> > > > >         Dim ff As New Form1
> > > > >         ff.BringToFront()
> > > > >         ff.soumavez(exitvar) ' this is the call to the sub in Form1
> > > > >     End Sub
> > > > >
> > > > > "rowe_newsgroups" wrote:
> > > > >
> > > > > > Please post the code that calls the sub.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Seth Rowe
> > > > > >
> > > > > > vitorjol wrote:
> > > > > > > Hello.
> > > > > > >
> > > > > > > I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
> > > > > > > form2, i get the error "object reference not set to an instance of an object"
> > > > > > > !
> > > > > > > What can i do to solve the problem?
> > > > > > >
> > > > > > > Thanks
> > > > > >
> > > > > >
> > > >
> > > >
> >
> >
Author
22 Sep 2006 5:30 AM
GhostInAK
Hello rowe_newsgroups,

Your solutuion would not work.  MGMapControl is the namespace.. MGMapLayer
is the type.  getMapObject is not static (shared).
pubvar2 (GEEZ!  Use some better freakin names next time wouldja, OP!) is
supposed to grab a reference to a specific map layer.

You are correct in that the OP is trying to use an object that is null.

OP:  Check your MWF, make sure you have a layer actually called "SIG".  Also,
ZoomSelected is a terrible way to get to an object.  First, the selection
will only succeed if the object is visible at your current zoom scale.  Second,
MapGuide is notorious for busystate collisions. 

-Boo

Show quoteHide quote
> Hmm. The "object reference not set to an instance of an object"
> exception is raised when you try to use an object that doesn't exist
> yet, like if you left out the New keyword. However, everything looks
> alright to me. The only thing I would try (outside of praying that
> someone else happens on this thread and sees what we're missing!) is
> to change this line:
>
>> pubmapobj = pubvar2.getMapObject(varin)
>>
> To this:
>
> pubmapobj = MGMapControl.MGMapLayer.getMapObject(varin)
>
> That will take the pubvar2 variable out of the equation. Note, you may
> also try throwing  the "New" keyword into that line, I'm not sure if
> you do or don't need it.
>
> Hope that helps,
>
> Seth Rowe
>
> vitorjol wrote:
>
>> Yes....im portuguese....but I love America!!!!!
>>
>> i forgot to tell U the line with the problem!!!Sorry
>>
>> So, the problem "object reference not set to an instance of an
>> object" occurs in the line >>pubmapobj = pubvar2.getMapObject(varin)
>>
>> Thanks
>>
>> "rowe_newsgroups" wrote:
>>
>>>> ok....the name "soumavez" its a name that i called to the Sub...End
>>>> Sub.
>>>>
>>> It looked like a foreign langauge to me (is it?), so I was just
>>> making sure it was a protected keyword in a foreign language edition
>>> of visual studio.
>>>
>>> Anyways, I have to apologize - my "visual" debugging skills must be
>>> lacking today, as I still don't see anything obviously wrong. Which
>>> line of the code raises the exception?
>>>
>>> Thanks,
>>>
>>> Seth Rowe
>>>
>>> vitorjol wrote:
>>>
>>>> i put here the code of Sub(its about the Mapguide ActiveX to show a
>>>> map in VB). I'll send there to Sub in the other form the id of a
>>>> polygon on the map, and then the Sub localize the polygon and zoom
>>>> the place!!!
>>>>
>>>> Code of the Sub "soumavez" in the Form1:
>>>>
>>>> Public Sub soumavez(ByVal varin As Integer)
>>>> ' --->"varin" its the var that i send from Form2!!!
>>>> ' --->"mgmap" its the name of the control (mapguide activex)
>>>> Try
>>>> Dim pubmapsel As MGMapControl.MGSelection
>>>> Dim pubvar2 As MGMapControl.MGMapLayer
>>>> Dim pubmapobjectos As MGMapControl.MGCollection
>>>> Dim pubmapobj As MGMapControl.MGMapObject
>>>> pubmapsel = mgmap.getSelection()
>>>> pubvar2 = mgmap.getMapLayer("SIG")
>>>> pubmapobjectos = mgmap.createObject("MGCollection")
>>>> pubmapobj = pubvar2.getMapObject(varin)
>>>> pubmapobjectos.add(pubmapobj)
>>>> pubmapsel.addObjectsEx(pubmapobjectos, False)
>>>> mgmap.zoomSelected()
>>>> mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
>>>> mgmap.refresh()
>>>> Catch ex As Exception
>>>> MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
>>>> MessageBoxIcon.Error)
>>>> End Try
>>>> End Sub
>>>> "rowe_newsgroups" wrote:
>>>>
>>>>> Looks like it should work, when you step through the code where
>>>>> does the exception occur?  If the error occurs in somewhere other
>>>>> than this sub please post that code too. Also what does "soumavez"
>>>>> mean?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Seth Rowe
>>>>>
>>>>> vitorjol wrote:
>>>>>
>>>>>> Here is the code:
>>>>>>
>>>>>> ' the code in form2
>>>>>> Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As
>>>>>> Object, ByVal
>>>>>> e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
>>>>>> DataGridView1.RowHeaderMouseClick
>>>>>> dim exitvar as Integer
>>>>>> exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
>>>>>> Dim ff As New Form1
>>>>>> ff.BringToFront()
>>>>>> ff.soumavez(exitvar) ' this is the call to the sub in Form1
>>>>>> End Sub
>>>>>> "rowe_newsgroups" wrote:
>>>>>>
>>>>>>> Please post the code that calls the sub.
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Seth Rowe
>>>>>>>
>>>>>>> vitorjol wrote:
>>>>>>>
>>>>>>>> Hello.
>>>>>>>>
>>>>>>>> I have 2 forms (Form1 and Form2). When i call the Sub placed in
>>>>>>>> form1 from
>>>>>>>> form2, i get the error "object reference not set to an instance
>>>>>>>> of an object"
>>>>>>>> !
>>>>>>>> What can i do to solve the problem?
>>>>>>>> Thanks
>>>>>>>>
Author
22 Sep 2006 8:07 AM
Daniel Bloch
What I see is that you do not show the form BringToFront does not make
a control a top-level control, and it does not raise the Paint event.

So with the knowledge of the last post, try following

- Check, if you can run the sub from form2 alone. Implement a button to
show what you want and make a test like this.
- If this does not work, first correct the sub until you are able to
let it run.
- After that, first show the new form and then let sub run from
form1...

Daniel
Author
22 Sep 2006 8:09 AM
Daniel Bloch
Daniel Bloch schrieb:

> What I see is that you do not show the form BringToFront does not make
> a control a top-level control, and it does not raise the Paint event.
>
> So with the knowledge of the last post, try following
>
> - Check, if you can run the sub from form2 alone. Implement a button to
> show what you want and make a test like this.
> - If this does not work, first correct the sub until you are able to
> let it run.
> - After that, first show the new form and then let sub run from
> form1...
>
> Daniel

Sorry, I did a mistake and mixed form1 and form2 :)
Author
22 Sep 2006 10:20 AM
vitorjol
The SUB in form2:

Public Sub soumavez(ByVal varin As Integer)
        Try
            MessageBox.Show(varin)                                         
            Dim pubmapsel As MGMapControl.MGSelection          
            Dim pubvar2 As MGMapControl.MGMapLayer             
            Dim pubmapobjectos As MGMapControl.MGCollection
            Dim pubmapobj As MGMapControl.MGMapObject
            pubmapsel = mgmap.getSelection()
            pubvar2 = mgmap.getMapLayer("SIG")
            pubmapobjectos = mgmap.createObject("MGCollection")
            pubmapobj = mgmap.getMapLayer("SIG").getMapObject(varin)
            pubmapobjectos.add(pubmapobj)
            mgmap.getSelection().addObjectsEx(pubmapobjectos, False)
            mgmap.zoomSelected()
            mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
            mgmap.refresh()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
MessageBoxIcon.Error)
        End Try

End Sub


this sub is called form Form2 with the following code:

        exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
        Dim ff As New Form1
        ff.BringToFront()
        ff.soumavez(exitvar)

PROBLEM:

if i dont put the codeline "MessageBox.Show(varin)", occurs the error at
line "pubmapobj = mgmap.getMapLayer("SIG").getMapObject(varin)".
If i put the message "MessageBox.Show(varin)", occurs the error at line
"mgmap.getSelection().addObjectsEx(pubmapobjectos, False)".

the test that u say to do (call the sub from a buttonclick within Form1)
occurs with NO Error!!!!

Thanks

Show quoteHide quote
"Daniel Bloch" wrote:

>
> Daniel Bloch schrieb:
>
> > What I see is that you do not show the form BringToFront does not make
> > a control a top-level control, and it does not raise the Paint event.
> >
> > So with the knowledge of the last post, try following
> >
> > - Check, if you can run the sub from form2 alone. Implement a button to
> > show what you want and make a test like this.
> > - If this does not work, first correct the sub until you are able to
> > let it run.
> > - After that, first show the new form and then let sub run from
> > form1...
> >
> > Daniel
>
> Sorry, I did a mistake and mixed form1 and form2 :)
>
>
Author
22 Sep 2006 10:25 AM
vitorjol
Resume my problem:


if i call the Sub located in Form1 from Form1 i get no error. If i call the
Sub from Form2 i get error. Why?

Thanks

Show quoteHide quote
"vitorjol" wrote:

> The SUB in form2:
>
> Public Sub soumavez(ByVal varin As Integer)
>         Try
>             MessageBox.Show(varin)                                         
>             Dim pubmapsel As MGMapControl.MGSelection          
>             Dim pubvar2 As MGMapControl.MGMapLayer             
>             Dim pubmapobjectos As MGMapControl.MGCollection
>             Dim pubmapobj As MGMapControl.MGMapObject
>             pubmapsel = mgmap.getSelection()
>             pubvar2 = mgmap.getMapLayer("SIG")
>             pubmapobjectos = mgmap.createObject("MGCollection")
>             pubmapobj = mgmap.getMapLayer("SIG").getMapObject(varin)
>             pubmapobjectos.add(pubmapobj)
>             mgmap.getSelection().addObjectsEx(pubmapobjectos, False)
>             mgmap.zoomSelected()
>             mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
>             mgmap.refresh()
>         Catch ex As Exception
>             MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
> MessageBoxIcon.Error)
>         End Try
>
> End Sub
>
>
> this sub is called form Form2 with the following code:
>
>         exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
>         Dim ff As New Form1
>         ff.BringToFront()
>         ff.soumavez(exitvar)
>
> PROBLEM:
>
> if i dont put the codeline "MessageBox.Show(varin)", occurs the error at
> line "pubmapobj = mgmap.getMapLayer("SIG").getMapObject(varin)".
> If i put the message "MessageBox.Show(varin)", occurs the error at line
> "mgmap.getSelection().addObjectsEx(pubmapobjectos, False)".
>
> the test that u say to do (call the sub from a buttonclick within Form1)
> occurs with NO Error!!!!
>
> Thanks
>
> "Daniel Bloch" wrote:
>
> >
> > Daniel Bloch schrieb:
> >
> > > What I see is that you do not show the form BringToFront does not make
> > > a control a top-level control, and it does not raise the Paint event.
> > >
> > > So with the knowledge of the last post, try following
> > >
> > > - Check, if you can run the sub from form2 alone. Implement a button to
> > > show what you want and make a test like this.
> > > - If this does not work, first correct the sub until you are able to
> > > let it run.
> > > - After that, first show the new form and then let sub run from
> > > form1...
> > >
> > > Daniel
> >
> > Sorry, I did a mistake and mixed form1 and form2 :)
> >
> >
Author
25 Sep 2006 6:46 AM
Daniel Bloch
Now, have you tried to first SHOW the document with the command "show"
before let running the sub.

I realy believe that your problem just occurs because there is no valid
form available (because it's not yet shown and has it's window handle)
that can take the form handlings of your map software ...

Daniel
Author
25 Sep 2006 8:59 AM
vitorjol
i have the form1 and form2 open....i dont have to do the show command to the
Form1...i think!!!!!

Show quoteHide quote
"Daniel Bloch" wrote:

> Now, have you tried to first SHOW the document with the command "show"
> before let running the sub.
>
> I realy believe that your problem just occurs because there is no valid
> form available (because it's not yet shown and has it's window handle)
> that can take the form handlings of your map software ...
>
> Daniel
>
>
Author
26 Sep 2006 8:57 AM
Daniel Bloch
Have you tried?

Sometimes, software development is not about thinking but about trying.
So give it a try and place a ".show" instead of ".bringtofront" and
check out, what happens.

Daniel
Author
26 Sep 2006 10:59 AM
vitorjol
it opens again the form1....i dont want this, and dont work anyway!!!
i think that i solved the problem. In form1 i open the form2 with the
command showdialog...just this!!!

Show quoteHide quote
"Daniel Bloch" wrote:

> Have you tried?
>
> Sometimes, software development is not about thinking but about trying.
> So give it a try and place a ".show" instead of ".bringtofront" and
> check out, what happens.
>
> Daniel
>
>
Author
26 Sep 2006 11:46 AM
Daniel Bloch
vitorjol schrieb:

Show quoteHide quote
> it opens again the form1....i dont want this, and dont work anyway!!!
> i think that i solved the problem. In form1 i open the form2 with the
> command showdialog...just this!!!
>
> "Daniel Bloch" wrote:
>
> > Have you tried?
> >
> > Sometimes, software development is not about thinking but about trying.
> > So give it a try and place a ".show" instead of ".bringtofront" and
> > check out, what happens.
> >
> > Daniel
> >
> >


Seems that we had a great misunderstanding - it's exactly what I tried
to propose ...

But already you have your solution and so it's also ok for me...
Daniel
Author
22 Sep 2006 10:47 AM
rowe_newsgroups
Thanks for coming to my rescue here Ghost, with no experience using
Mapguide (and not having it's SDK) I was getting in over my head!

Thanks,

Seth Rowe

GhostInAK wrote:
Show quoteHide quote
> Hello rowe_newsgroups,
>
> Your solutuion would not work.  MGMapControl is the namespace.. MGMapLayer
> is the type.  getMapObject is not static (shared).
> pubvar2 (GEEZ!  Use some better freakin names next time wouldja, OP!) is
> supposed to grab a reference to a specific map layer.
>
> You are correct in that the OP is trying to use an object that is null.
>
> OP:  Check your MWF, make sure you have a layer actually called "SIG".  Also,
> ZoomSelected is a terrible way to get to an object.  First, the selection
> will only succeed if the object is visible at your current zoom scale.  Second,
> MapGuide is notorious for busystate collisions.
>
> -Boo
>
> > Hmm. The "object reference not set to an instance of an object"
> > exception is raised when you try to use an object that doesn't exist
> > yet, like if you left out the New keyword. However, everything looks
> > alright to me. The only thing I would try (outside of praying that
> > someone else happens on this thread and sees what we're missing!) is
> > to change this line:
> >
> >> pubmapobj = pubvar2.getMapObject(varin)
> >>
> > To this:
> >
> > pubmapobj = MGMapControl.MGMapLayer.getMapObject(varin)
> >
> > That will take the pubvar2 variable out of the equation. Note, you may
> > also try throwing  the "New" keyword into that line, I'm not sure if
> > you do or don't need it.
> >
> > Hope that helps,
> >
> > Seth Rowe
> >
> > vitorjol wrote:
> >
> >> Yes....im portuguese....but I love America!!!!!
> >>
> >> i forgot to tell U the line with the problem!!!Sorry
> >>
> >> So, the problem "object reference not set to an instance of an
> >> object" occurs in the line >>pubmapobj = pubvar2.getMapObject(varin)
> >>
> >> Thanks
> >>
> >> "rowe_newsgroups" wrote:
> >>
> >>>> ok....the name "soumavez" its a name that i called to the Sub...End
> >>>> Sub.
> >>>>
> >>> It looked like a foreign langauge to me (is it?), so I was just
> >>> making sure it was a protected keyword in a foreign language edition
> >>> of visual studio.
> >>>
> >>> Anyways, I have to apologize - my "visual" debugging skills must be
> >>> lacking today, as I still don't see anything obviously wrong. Which
> >>> line of the code raises the exception?
> >>>
> >>> Thanks,
> >>>
> >>> Seth Rowe
> >>>
> >>> vitorjol wrote:
> >>>
> >>>> i put here the code of Sub(its about the Mapguide ActiveX to show a
> >>>> map in VB). I'll send there to Sub in the other form the id of a
> >>>> polygon on the map, and then the Sub localize the polygon and zoom
> >>>> the place!!!
> >>>>
> >>>> Code of the Sub "soumavez" in the Form1:
> >>>>
> >>>> Public Sub soumavez(ByVal varin As Integer)
> >>>> ' --->"varin" its the var that i send from Form2!!!
> >>>> ' --->"mgmap" its the name of the control (mapguide activex)
> >>>> Try
> >>>> Dim pubmapsel As MGMapControl.MGSelection
> >>>> Dim pubvar2 As MGMapControl.MGMapLayer
> >>>> Dim pubmapobjectos As MGMapControl.MGCollection
> >>>> Dim pubmapobj As MGMapControl.MGMapObject
> >>>> pubmapsel = mgmap.getSelection()
> >>>> pubvar2 = mgmap.getMapLayer("SIG")
> >>>> pubmapobjectos = mgmap.createObject("MGCollection")
> >>>> pubmapobj = pubvar2.getMapObject(varin)
> >>>> pubmapobjectos.add(pubmapobj)
> >>>> pubmapsel.addObjectsEx(pubmapobjectos, False)
> >>>> mgmap.zoomSelected()
> >>>> mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
> >>>> mgmap.refresh()
> >>>> Catch ex As Exception
> >>>> MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
> >>>> MessageBoxIcon.Error)
> >>>> End Try
> >>>> End Sub
> >>>> "rowe_newsgroups" wrote:
> >>>>
> >>>>> Looks like it should work, when you step through the code where
> >>>>> does the exception occur?  If the error occurs in somewhere other
> >>>>> than this sub please post that code too. Also what does "soumavez"
> >>>>> mean?
> >>>>>
> >>>>> Thanks,
> >>>>>
> >>>>> Seth Rowe
> >>>>>
> >>>>> vitorjol wrote:
> >>>>>
> >>>>>> Here is the code:
> >>>>>>
> >>>>>> ' the code in form2
> >>>>>> Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As
> >>>>>> Object, ByVal
> >>>>>> e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
> >>>>>> DataGridView1.RowHeaderMouseClick
> >>>>>> dim exitvar as Integer
> >>>>>> exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
> >>>>>> Dim ff As New Form1
> >>>>>> ff.BringToFront()
> >>>>>> ff.soumavez(exitvar) ' this is the call to the sub in Form1
> >>>>>> End Sub
> >>>>>> "rowe_newsgroups" wrote:
> >>>>>>
> >>>>>>> Please post the code that calls the sub.
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>>
> >>>>>>> Seth Rowe
> >>>>>>>
> >>>>>>> vitorjol wrote:
> >>>>>>>
> >>>>>>>> Hello.
> >>>>>>>>
> >>>>>>>> I have 2 forms (Form1 and Form2). When i call the Sub placed in
> >>>>>>>> form1 from
> >>>>>>>> form2, i get the error "object reference not set to an instance
> >>>>>>>> of an object"
> >>>>>>>> !
> >>>>>>>> What can i do to solve the problem?
> >>>>>>>> Thanks
> >>>>>>>>
Author
23 Sep 2006 2:29 AM
GhostInAK
Hello rowe_newsgroups,

I envy you, Seth.  I have to use the abismal peice of crap every day.

-Boo

Show quoteHide quote
> Thanks for coming to my rescue here Ghost, with no experience using
> Mapguide (and not having it's SDK) I was getting in over my head!
>
> Thanks,
>
> Seth Rowe
>
> GhostInAK wrote:
>
>> Hello rowe_newsgroups,
>>
>> Your solutuion would not work.  MGMapControl is the namespace..
>> MGMapLayer
>> is the type.  getMapObject is not static (shared).
>> pubvar2 (GEEZ!  Use some better freakin names next time wouldja, OP!)
>> is
>> supposed to grab a reference to a specific map layer.
>> You are correct in that the OP is trying to use an object that is
>> null.
>>
>> OP:  Check your MWF, make sure you have a layer actually called
>> "SIG".  Also,
>> ZoomSelected is a terrible way to get to an object.  First, the
>> selection
>> will only succeed if the object is visible at your current zoom
>> scale.  Second,
>> MapGuide is notorious for busystate collisions.
>> -Boo
>>
>>> Hmm. The "object reference not set to an instance of an object"
>>> exception is raised when you try to use an object that doesn't exist
>>> yet, like if you left out the New keyword. However, everything looks
>>> alright to me. The only thing I would try (outside of praying that
>>> someone else happens on this thread and sees what we're missing!) is
>>> to change this line:
>>>
>>>> pubmapobj = pubvar2.getMapObject(varin)
>>>>
>>> To this:
>>>
>>> pubmapobj = MGMapControl.MGMapLayer.getMapObject(varin)
>>>
>>> That will take the pubvar2 variable out of the equation. Note, you
>>> may also try throwing  the "New" keyword into that line, I'm not
>>> sure if you do or don't need it.
>>>
>>> Hope that helps,
>>>
>>> Seth Rowe
>>>
>>> vitorjol wrote:
>>>
>>>> Yes....im portuguese....but I love America!!!!!
>>>>
>>>> i forgot to tell U the line with the problem!!!Sorry
>>>>
>>>> So, the problem "object reference not set to an instance of an
>>>> object" occurs in the line >>pubmapobj =
>>>> pubvar2.getMapObject(varin)
>>>>
>>>> Thanks
>>>>
>>>> "rowe_newsgroups" wrote:
>>>>
>>>>>> ok....the name "soumavez" its a name that i called to the
>>>>>> Sub...End Sub.
>>>>>>
>>>>> It looked like a foreign langauge to me (is it?), so I was just
>>>>> making sure it was a protected keyword in a foreign language
>>>>> edition of visual studio.
>>>>>
>>>>> Anyways, I have to apologize - my "visual" debugging skills must
>>>>> be lacking today, as I still don't see anything obviously wrong.
>>>>> Which line of the code raises the exception?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Seth Rowe
>>>>>
>>>>> vitorjol wrote:
>>>>>
>>>>>> i put here the code of Sub(its about the Mapguide ActiveX to show
>>>>>> a map in VB). I'll send there to Sub in the other form the id of
>>>>>> a polygon on the map, and then the Sub localize the polygon and
>>>>>> zoom the place!!!
>>>>>>
>>>>>> Code of the Sub "soumavez" in the Form1:
>>>>>>
>>>>>> Public Sub soumavez(ByVal varin As Integer)
>>>>>> ' --->"varin" its the var that i send from Form2!!!
>>>>>> ' --->"mgmap" its the name of the control (mapguide activex)
>>>>>> Try
>>>>>> Dim pubmapsel As MGMapControl.MGSelection
>>>>>> Dim pubvar2 As MGMapControl.MGMapLayer
>>>>>> Dim pubmapobjectos As MGMapControl.MGCollection
>>>>>> Dim pubmapobj As MGMapControl.MGMapObject
>>>>>> pubmapsel = mgmap.getSelection()
>>>>>> pubvar2 = mgmap.getMapLayer("SIG")
>>>>>> pubmapobjectos = mgmap.createObject("MGCollection")
>>>>>> pubmapobj = pubvar2.getMapObject(varin)
>>>>>> pubmapobjectos.add(pubmapobj)
>>>>>> pubmapsel.addObjectsEx(pubmapobjectos, False)
>>>>>> mgmap.zoomSelected()
>>>>>> mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
>>>>>> mgmap.refresh()
>>>>>> Catch ex As Exception
>>>>>> MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
>>>>>> MessageBoxIcon.Error)
>>>>>> End Try
>>>>>> End Sub
>>>>>> "rowe_newsgroups" wrote:
>>>>>>> Looks like it should work, when you step through the code where
>>>>>>> does the exception occur?  If the error occurs in somewhere
>>>>>>> other than this sub please post that code too. Also what does
>>>>>>> "soumavez" mean?
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Seth Rowe
>>>>>>>
>>>>>>> vitorjol wrote:
>>>>>>>
>>>>>>>> Here is the code:
>>>>>>>>
>>>>>>>> ' the code in form2
>>>>>>>> Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As
>>>>>>>> Object, ByVal
>>>>>>>> e As System.Windows.Forms.DataGridViewCellMouseEventArgs)
>>>>>>>> Handles
>>>>>>>> DataGridView1.RowHeaderMouseClick
>>>>>>>> dim exitvar as Integer
>>>>>>>> exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
>>>>>>>> Dim ff As New Form1
>>>>>>>> ff.BringToFront()
>>>>>>>> ff.soumavez(exitvar) ' this is the call to the sub in Form1
>>>>>>>> End Sub
>>>>>>>> "rowe_newsgroups" wrote:
>>>>>>>>> Please post the code that calls the sub.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Seth Rowe
>>>>>>>>>
>>>>>>>>> vitorjol wrote:
>>>>>>>>>
>>>>>>>>>> Hello.
>>>>>>>>>>
>>>>>>>>>> I have 2 forms (Form1 and Form2). When i call the Sub placed
>>>>>>>>>> in
>>>>>>>>>> form1 from
>>>>>>>>>> form2, i get the error "object reference not set to an
>>>>>>>>>> instance
>>>>>>>>>> of an object"
>>>>>>>>>> !
>>>>>>>>>> What can i do to solve the problem?
>>>>>>>>>> Thanks
Author
23 Sep 2006 8:30 AM
vitorjol
Can i force the execution of the Button_click located in Form1 from Form2?

i ask this because in Form1, if i execute the sub called from the
button_click everything goes right, but if i call the sub outside the Form1
(Form2) occurs the error!!!

Thanks

Show quoteHide quote
"GhostInAK" wrote:

> Hello rowe_newsgroups,
>
> I envy you, Seth.  I have to use the abismal peice of crap every day.
>
> -Boo
>
> > Thanks for coming to my rescue here Ghost, with no experience using
> > Mapguide (and not having it's SDK) I was getting in over my head!
> >
> > Thanks,
> >
> > Seth Rowe
> >
> > GhostInAK wrote:
> >
> >> Hello rowe_newsgroups,
> >>
> >> Your solutuion would not work.  MGMapControl is the namespace..
> >> MGMapLayer
> >> is the type.  getMapObject is not static (shared).
> >> pubvar2 (GEEZ!  Use some better freakin names next time wouldja, OP!)
> >> is
> >> supposed to grab a reference to a specific map layer.
> >> You are correct in that the OP is trying to use an object that is
> >> null.
> >>
> >> OP:  Check your MWF, make sure you have a layer actually called
> >> "SIG".  Also,
> >> ZoomSelected is a terrible way to get to an object.  First, the
> >> selection
> >> will only succeed if the object is visible at your current zoom
> >> scale.  Second,
> >> MapGuide is notorious for busystate collisions.
> >> -Boo
> >>
> >>> Hmm. The "object reference not set to an instance of an object"
> >>> exception is raised when you try to use an object that doesn't exist
> >>> yet, like if you left out the New keyword. However, everything looks
> >>> alright to me. The only thing I would try (outside of praying that
> >>> someone else happens on this thread and sees what we're missing!) is
> >>> to change this line:
> >>>
> >>>> pubmapobj = pubvar2.getMapObject(varin)
> >>>>
> >>> To this:
> >>>
> >>> pubmapobj = MGMapControl.MGMapLayer.getMapObject(varin)
> >>>
> >>> That will take the pubvar2 variable out of the equation. Note, you
> >>> may also try throwing  the "New" keyword into that line, I'm not
> >>> sure if you do or don't need it.
> >>>
> >>> Hope that helps,
> >>>
> >>> Seth Rowe
> >>>
> >>> vitorjol wrote:
> >>>
> >>>> Yes....im portuguese....but I love America!!!!!
> >>>>
> >>>> i forgot to tell U the line with the problem!!!Sorry
> >>>>
> >>>> So, the problem "object reference not set to an instance of an
> >>>> object" occurs in the line >>pubmapobj =
> >>>> pubvar2.getMapObject(varin)
> >>>>
> >>>> Thanks
> >>>>
> >>>> "rowe_newsgroups" wrote:
> >>>>
> >>>>>> ok....the name "soumavez" its a name that i called to the
> >>>>>> Sub...End Sub.
> >>>>>>
> >>>>> It looked like a foreign langauge to me (is it?), so I was just
> >>>>> making sure it was a protected keyword in a foreign language
> >>>>> edition of visual studio.
> >>>>>
> >>>>> Anyways, I have to apologize - my "visual" debugging skills must
> >>>>> be lacking today, as I still don't see anything obviously wrong.
> >>>>> Which line of the code raises the exception?
> >>>>>
> >>>>> Thanks,
> >>>>>
> >>>>> Seth Rowe
> >>>>>
> >>>>> vitorjol wrote:
> >>>>>
> >>>>>> i put here the code of Sub(its about the Mapguide ActiveX to show
> >>>>>> a map in VB). I'll send there to Sub in the other form the id of
> >>>>>> a polygon on the map, and then the Sub localize the polygon and
> >>>>>> zoom the place!!!
> >>>>>>
> >>>>>> Code of the Sub "soumavez" in the Form1:
> >>>>>>
> >>>>>> Public Sub soumavez(ByVal varin As Integer)
> >>>>>> ' --->"varin" its the var that i send from Form2!!!
> >>>>>> ' --->"mgmap" its the name of the control (mapguide activex)
> >>>>>> Try
> >>>>>> Dim pubmapsel As MGMapControl.MGSelection
> >>>>>> Dim pubvar2 As MGMapControl.MGMapLayer
> >>>>>> Dim pubmapobjectos As MGMapControl.MGCollection
> >>>>>> Dim pubmapobj As MGMapControl.MGMapObject
> >>>>>> pubmapsel = mgmap.getSelection()
> >>>>>> pubvar2 = mgmap.getMapLayer("SIG")
> >>>>>> pubmapobjectos = mgmap.createObject("MGCollection")
> >>>>>> pubmapobj = pubvar2.getMapObject(varin)
> >>>>>> pubmapobjectos.add(pubmapobj)
> >>>>>> pubmapsel.addObjectsEx(pubmapobjectos, False)
> >>>>>> mgmap.zoomSelected()
> >>>>>> mgmap.zoomScale(mgmap.getLat(), mgmap.getLon(), 1500)
> >>>>>> mgmap.refresh()
> >>>>>> Catch ex As Exception
> >>>>>> MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK,
> >>>>>> MessageBoxIcon.Error)
> >>>>>> End Try
> >>>>>> End Sub
> >>>>>> "rowe_newsgroups" wrote:
> >>>>>>> Looks like it should work, when you step through the code where
> >>>>>>> does the exception occur?  If the error occurs in somewhere
> >>>>>>> other than this sub please post that code too. Also what does
> >>>>>>> "soumavez" mean?
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>>
> >>>>>>> Seth Rowe
> >>>>>>>
> >>>>>>> vitorjol wrote:
> >>>>>>>
> >>>>>>>> Here is the code:
> >>>>>>>>
> >>>>>>>> ' the code in form2
> >>>>>>>> Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As
> >>>>>>>> Object, ByVal
> >>>>>>>> e As System.Windows.Forms.DataGridViewCellMouseEventArgs)
> >>>>>>>> Handles
> >>>>>>>> DataGridView1.RowHeaderMouseClick
> >>>>>>>> dim exitvar as Integer
> >>>>>>>> exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
> >>>>>>>> Dim ff As New Form1
> >>>>>>>> ff.BringToFront()
> >>>>>>>> ff.soumavez(exitvar) ' this is the call to the sub in Form1
> >>>>>>>> End Sub
> >>>>>>>> "rowe_newsgroups" wrote:
> >>>>>>>>> Please post the code that calls the sub.
> >>>>>>>>>
> >>>>>>>>> Thanks,
> >>>>>>>>>
> >>>>>>>>> Seth Rowe
> >>>>>>>>>
> >>>>>>>>> vitorjol wrote:
> >>>>>>>>>
> >>>>>>>>>> Hello.
> >>>>>>>>>>
> >>>>>>>>>> I have 2 forms (Form1 and Form2). When i call the Sub placed
> >>>>>>>>>> in
> >>>>>>>>>> form1 from
> >>>>>>>>>> form2, i get the error "object reference not set to an
> >>>>>>>>>> instance
> >>>>>>>>>> of an object"
> >>>>>>>>>> !
> >>>>>>>>>> What can i do to solve the problem?
> >>>>>>>>>> Thanks
>
>
>