0

Maybe is a simple question, but I am not able to find nothing useful for me.

I am trying to debug my program in VB.NET, and I am trying to add an inspection of a comparision. The problem I am having is that the two variables of the comparision are from other forms, so when I try to see the result of the inspection, I am getting the following for both variables:

"reference to a non-shared member requires an object reference vb.net 2010"

My code is:

Private Sub YESButton_Click(sender As Object, e As EventArgs) Handles YESButton.Click
    If frmTargetList.delete_Selected_All_targets = 1 Then
        'Lo borro de targetListFromBBDD, TARGETS_Overlay, TARGETS_Overlay_Damaged, TARGETS_Overlay_Eliminated, targetMarkers, selectedMultipleTargetclsPosition
        For i As Integer = 0 To BMS.targetListFromBBDD.Count - 1
            If frmTargetList.targetToDelete = BMS.targetMarkers(i).id Then
                BMS.DeleteTargetFromBBDD(BMS.targetMarkers(i).id)
                Dim marker As GMarkerGoogle
                marker = BMS.targetMarkers(i).marker
                BMS.TARGETS_Overlay.Markers.Remove(marker)
                BMS.TARGETS_Overlay_Damaged.Markers.Remove(marker)
                BMS.TARGETS_Overlay_Eliminated.Markers.Remove(marker)
                BMS.targetMarkers.Remove(New clsPosition(marker.ToolTipText, marker.Position.Lat.ToString, marker.Position.Lng.ToString))
                BMS.selectedMultipleTargetclsPosition.Remove(New clsPosition(marker.ToolTipText, marker.Position.Lat.ToString, marker.Position.Lng.ToString))
            End If
        Next
        'Lo borro de targetList
        For j As Integer = 1 To BMS.targetList.Count
            If frmTargetList.targetToDelete = BMS.targetList(j).id Then
                BMS.targetList(j) = Nothing
            End If
        Next

        frmTargetList.TargetsListView.SelectedItems(0).Remove()

    ElseIf frmTargetList.delete_Selected_All_targets = 2 Then
        BMS.TARGETS_Overlay.Markers.Clear()
        BMS.TARGETS_Overlay_Damaged.Markers.Clear()
        BMS.TARGETS_Overlay_Eliminated.Markers.Clear()
        BMS.targetListFromBBDD.Clear()
        BMS.targetList.Clear()
        BMS.targetMarkers.Clear()
        BMS.selectedMultipleTargetclsPosition.Clear()
        BMS.targetId = 1
        BMS.targetInserted = 0
        BMS.DeleteAllTargetFromBBDD()
        frmTargetList.TargetsListView.Clear()
        BMS.myOverlayDistances.Clear()
    End If

    Me.Close()
    frmTargetList.Close()
End Sub

And in this line:

 If frmTargetList.targetToDelete = BMS.targetMarkers(i).id Then

is where I am not able to see what is happening, but the execution does not continue and I can not see why.

If needed, both variables are public, and are declarated in forms that are in the same project. Also, I am checking that during the flow of the program, that variables have value, so I think that the problem is that this variables does not match, but when I execute the program to make them match, neither continues and exit.

There some way to do an inspection of variables that are in other forms?

Thanks to everyone

daniel lozano
  • 421
  • 6
  • 19
  • Try adding two extra variables and assign them values with `frmTargetList.targetToDelete`, `BMS.targetMarkers(i).id`. Eg: `Dim a As Integer = frmTargetList.targetToDelete` & `Dim b As Integer = BMS.targetMarkers(i).id` Then replace the `If` condition with these variables and do the inspection on them – boop_the_snoot Jul 18 '17 at 10:13
  • What an easy way! I don't know why I wasn't think about this! I have tried it, and I see that one of the variables has value before the program goes in to the function, but inside, is like this variable lose its value. I don't know why because I have not any line that reset the variable. This one is the problematic variable: frmTargetList.targetToDelete – daniel lozano Jul 18 '17 at 10:22
  • I guess `frmTargetList` is your `Form`, but what is `targetToDelete`? Is this a `Property`? – boop_the_snoot Jul 18 '17 at 10:28
  • Yes sorry, frmTargetList is the form, and targetToDelete is a public variable of that form – daniel lozano Jul 18 '17 at 12:11

0 Answers0