none
Continuation of the last error between mouse click to move sprite and mouseclick to attack sprite

    Question

  • This is all a recap because the last thread got really messed up so what is in the last post is being referred here. Nobody go to the last thread, msg on here now. 

        ', Sender As Object
        Private Sub Pics_MouseDown(ByVal obj As Object, e As MouseEventArgs) Handles MyBase.MouseDown
            If TankSelectStatus = 1 Then
                'select the action
                TargetSprite = DirectCast(Sender, PictureBox).Name
                TankSelectStatus = 0
            Else
                'show the menu
                TankToolbar.Visible = True
            End If
    
            If e.Button = MouseButtons.Left Then
                For Each spt As Sprite In Sprites
                    If spt.Pic Is DirectCast(obj, PictureBox) Then
                        If spt.Visible = 2 Then
                            'move the sprite
                            MouseDownPicLocation = spt.Pic.Location
                            MouseDownLocation = e.Location
                            MouseDownSprite = spt
                            spt.Pic.BringToFront()
                        Else
                            'Select the sprite
                            MouseDownSprite = Nothing
                        End If
                        Exit For
                    End If
                Next
            End If
    
            If e.Button = MouseButtons.Right Then
                'popup the menu
                Dim AttackListIndex = GetSpriteIndex(AttackListIndex)
                Dim TargetListIndex = GetSpriteIndex(TargetListIndex)
                Dim hp As Integer = Sprites(TargetListIndex).HP - Sprites(AttackListIndex).AP
    
                If hp <= 0 Then
                    MsgBox(Sprites(TargetListIndex).Name & " Murked by " & Sprites(AttackListIndex).Name)
                    Sprites(AttackListIndex).HP += Sprites(TargetListIndex).HP
                    'remove sprite from list
                    Sprites(TargetListIndex).Pic.Dispose()
                    Sprites.Remove(Sprites(TargetListIndex))
                Else
                    Sprites(TargetListIndex).HP = Sprites(TargetListIndex).HP - Sprites(AttackListIndex).AP
                    MsgBox("Still standing")
                End If
            Else
                'reset the tools
                AttackSprite = DirectCast(Sender, PictureBox).Name
                TankToolbar.Location = New Point(Sprites(GetSpriteIndex(AttackSprite)).Pic.Right, Sprites(GetSpriteIndex(AttackSprite)).Pic.Bottom)
                TankToolbar.Visible = True
            End If
        End Sub
    ---------------------------------------------------------------------------------------------------------------------
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            DoubleBuffered = True
            Sprites.Add(New Sprite)
            Sprites.Add(New Sprite)
            Sprites.Add(New Sprite)
            Sprites(0).Name = "Light Battle"
            Sprites(0).HP = 10
            Sprites(0).AP = 5
            Sprites(1).Name = "Heavy Panzer"
            Sprites(1).HP = 10
            Sprites(1).AP = 5
            Sprites(2).Name = "Heavy Scorcher"
            Sprites(2).HP = 10
            Sprites(2).AP = 5
            Sprites(0).ColRow = New Point(3, 2)
            Sprites(1).ColRow = New Point(4, 5)
            Sprites(2).ColRow = New Point(2, 2)
    
            For i = 0 To 2
                Dim pic = New PictureBox()
                With pic
                    .Name = "Pic" & i.ToString
                    .Size = GridSize
                    .BackgroundImageLayout = ImageLayout.Stretch
                    Dim ImageFile As String = IO.Path.Combine("N:\Documents\Visual Studio 2015\Projects\Most Recent Testings\", Sprites(i).Name & ".png")
                    'Dim ImageFile As String = IO.Path.Combine("C:\Users\BusinessOffice1Room\Documents\", Sprites(i).Name & ".png")
                    .BackgroundImage = Image.FromFile(ImageFile)
                    Me.Controls.Add(pic)
                    AddHandler .MouseDown, AddressOf Pics_MouseDown
                    AddHandler .MouseMove, AddressOf pics_MouseMove
                    AddHandler .MouseUp, AddressOf pics_MouseUp
                End With
                Sprites(i).Pic = pic
            Next
            Form1_Resize(1, Nothing)
        End Sub


    WRA

    Monday, March 27, 2017 2:44 PM

Answers

  • Sounds like a good idea. I still have time to develop my program so I'll take problems slowly. Before I look back into the three old programs Im going to first finish off what schoolwork I have at the moment then I'll look at those programs you reccomend and understand what to do to approach the solution.

    I found the approach of typing out the code a great method when it comes to understanding something and when I do I find something in there which contrast to what I have done. 


    WRA


    We have 3 things we are working with right now. A Sprite Class that we defined, A List of Sprite Class objects, and A Picturebox object (I guess object is the correct term?).

    We just added the picturebox object to our sprite class for convenience. The sprite class stores data and part of the data in a sprite class object is a Picturebox object.

    Both the sprite and the picturebox have .name properties. So that gets confusing. We dont even need to use them. Or we can. And thats what is being worked out.

    Like the engine in a car. Car is the class engine is the variable. Execept in our case it is only code and does not really exist except in our minds. Its not really a picturebox. Its just more code that is the picturebox class. In the class the .name is declared just like in our sprite.

    So in your current code example here there is sprites(1).name = "Heavy Panzer" and there is sprites(1).pic.name = "pic 1" .

    Also note the names are just strings. They dont mean anything in the code other than it is the name we gave it for whatever reason.

    PS so in the car model you would have car.name = "corvette" and car.engine.name ="427".

    Monday, March 27, 2017 6:17 PM

All replies

  • Here are the errors 

    WRA

    Monday, March 27, 2017 2:45 PM
  • Tommy has referred to some examples so that is where I need to look to find my answers from. 

    WRA

    Monday, March 27, 2017 2:46 PM
  • Tommy has referred to some examples so that is where I need to look to find my answers from. 

    WRA

    Wali,

    Study the three examples from the end of this other thread and if you have questions about those three examples then ask them here. Post all the info required to understand your question.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/6be8a21d-84ef-4967-9a8b-d53ef5a8fd97/conflict-between-two-mousedowns?forum=vbgeneral

    You should not try to work on the code you posted here until you understand the last three examples. All you are doing is making things more confusing for everyone.

    Monday, March 27, 2017 2:53 PM
  • PS Wali,

    The code you posted here is better. Close to something that will work but not quite as you see. I have not studied it yet.

    But lets be sure you are understanding the past examples before moving on. So you study and come back with your current questions and I will try not to muck this thread up.

    Monday, March 27, 2017 3:17 PM
  • And another thing. :)

    Note how errors stack up and lead to more errors and you fix this one and then suddenly there are ten more. Gets almost impossible to sort out if there are many unknown errors.

    Thats why we do one step at a time (besides to sort things in our brains) and then run the project and see if that step worked and if not debug it. We dont add 22 new things or then we get 22 new errors.

    So we add just the amount of code we understand and run and debug that before moving on to new errors.

    Monday, March 27, 2017 3:32 PM
  • Sounds like a good idea. I still have time to develop my program so I'll take problems slowly. Before I look back into the three old programs Im going to first finish off what schoolwork I have at the moment then I'll look at those programs you reccomend and understand what to do to approach the solution.

    I found the approach of typing out the code a great method when it comes to understanding something and when I do I find something in there which contrast to what I have done. 


    WRA

    Monday, March 27, 2017 5:28 PM
  • Hi

    Confused! The first lines I looked at:

      ', Sender As Object
        Private Sub Pics_MouseDown(ByVal obj As Object, e As MouseEventArgs) Handles MyBase.MouseDown
            If TankSelectStatus = 1 Then
                'select the action
                TargetSprite = DirectCast(Sender, PictureBox).Name
    Did you change 'Sender' to 'Obj' in the signature - and then go on to try and use 'Sender' in the DirectCast? There really should be matching variable names if you are to stand a chance.


    Regards Les, Livingston, Scotland

    Monday, March 27, 2017 5:43 PM
  • Sounds like a good idea. I still have time to develop my program so I'll take problems slowly. Before I look back into the three old programs Im going to first finish off what schoolwork I have at the moment then I'll look at those programs you reccomend and understand what to do to approach the solution.

    I found the approach of typing out the code a great method when it comes to understanding something and when I do I find something in there which contrast to what I have done. 


    WRA


    We have 3 things we are working with right now. A Sprite Class that we defined, A List of Sprite Class objects, and A Picturebox object (I guess object is the correct term?).

    We just added the picturebox object to our sprite class for convenience. The sprite class stores data and part of the data in a sprite class object is a Picturebox object.

    Both the sprite and the picturebox have .name properties. So that gets confusing. We dont even need to use them. Or we can. And thats what is being worked out.

    Like the engine in a car. Car is the class engine is the variable. Execept in our case it is only code and does not really exist except in our minds. Its not really a picturebox. Its just more code that is the picturebox class. In the class the .name is declared just like in our sprite.

    So in your current code example here there is sprites(1).name = "Heavy Panzer" and there is sprites(1).pic.name = "pic 1" .

    Also note the names are just strings. They dont mean anything in the code other than it is the name we gave it for whatever reason.

    PS so in the car model you would have car.name = "corvette" and car.engine.name ="427".

    Monday, March 27, 2017 6:17 PM
  • I like to context you put it into. You should do this more often tommy when I get into situations. 

    WRA

    Monday, March 27, 2017 6:49 PM
  • This is all a recap because the last thread got really messed up so what is in the last post is being referred here.

    If you want to use this:

        TargetSprite = DirectCast(sender, PictureBox).Name

    Then you have to change

        With pic
          .Name = "Pic" & i.ToString

    in the form load event to

       With pic
         .Name = Sprites(i).Name

    so that the picturebox name for the picturebox that you assign to the sprite really does have the name of the sprite.   That is an example of adapting code examples to your specific circumstance.

    Monday, March 27, 2017 8:44 PM
  • Afternoon all, tomorrow is when I'll take a shot at solving this problem since the current situation is I need to hand in whatever I have for my coursework for it to be marked.  I'm going full on in the easter holidays with the primary objective to complete Project State of War.

    Eversince opening an account to this forum I have learnt many things from well experienced programmers. Especially tommy, acamar, cor, ironrazzors and others. 

     

    WRA


    Wednesday, March 29, 2017 11:24 AM
  • Afternoon everyone I am back on the forums and going to figure out a solution to my problem relating to the lmb and rmb. 

    I'm gonna type out the given solutions. I find its the best way for me to process things and find a solution to a given problem. 


    WRA

    Thursday, March 30, 2017 2:36 PM
  • Thanks Acamar that has solved most of the Issue now the problem that arises is to do with the attacklistindex which I should be able to figure out otherwise Ill post a msg if there is anything wrong. 

    WRA

    Thursday, March 30, 2017 3:24 PM
  • I found the problem where it was: here. whilst I was retyping some code that tommy sent on here I decided to jog my memory by typing some of them out to find the solution and I realised this part didn't make any sense and I corrected it. 

                Dim AttackListIndex = GetSpriteIndex(AttackSprite)
                Dim TargetListIndex = GetSpriteIndex(TargetSprite)

    That above is the correct answer

    I realise I did this: I was calling itself which made no logical sense there. 

                Dim AttackListIndex = GetSpriteIndex(AttackListIndex)
                Dim TargetListIndex = GetSpriteIndex(TargetListIndex)

    Now Im on this last problem where I need to actually fuse the two together but first Im gonna still jog my memory by typing out the 2nd code to do with removing the color sprites then the other one to do with rotating the tank etc. 

        Private Sub Pics_MouseDown(ByVal obj As Object, Sender As Object, e As MouseEventArgs)

    This private sub here says the error that it does not have a signature compatible with delegate "delegate Sub MouseEventHandler(sender As Obect, e As MouseEventArgs)"



    WRA

    Thursday, March 30, 2017 3:45 PM
  • This private sub here says the error that it does not have a signature compatible with delegate "delegate Sub MouseEventHandler(sender As Obect, e As MouseEventArgs)"

    I am stuck on this problem at the moment. Could anyone possibly point out where could I be going wrong?

        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'Load all the given sprites
            DoubleBuffered = True
            Sprites.Add(New Sprite)
            Sprites.Add(New Sprite)
            Sprites.Add(New Sprite)
            Sprites(0).Name = "Light Battle"
            Sprites(0).HP = 10
            Sprites(0).AP = 5
            Sprites(1).Name = "Heavy Panzer"
            Sprites(1).HP = 10
            Sprites(1).AP = 5
            Sprites(2).Name = "Heavy Scorcher"
            Sprites(2).HP = 10
            Sprites(2).AP = 5
            Sprites(0).ColRow = New Point(3, 2)
            Sprites(1).ColRow = New Point(4, 5)
            Sprites(2).ColRow = New Point(2, 2)
    
            'Load the image of it from a file
            For i = 0 To 2
                Dim pic = New PictureBox()
                With pic
                    .Name = Sprites(i).ToString
                    .Size = GridSize
                    .BackgroundImageLayout = ImageLayout.Stretch
                    Dim ImageFile As String = IO.Path.Combine("C:\Users\BusinessOffice1Room\Documents\", Sprites(i).Name & ".png")
                    .BackgroundImage = Image.FromFile(ImageFile)
                    Me.Controls.Add(pic)
                    'Carry Out functions with mousebuttons
                    AddHandler .MouseDown, AddressOf Pics_MouseDown 'Where the error takes place
                    AddHandler .MouseMove, AddressOf pics_MouseMove
                    AddHandler .MouseUp, AddressOf pics_MouseUp
                End With
                Sprites(i).Pic = pic
            Next
            Form1_Resize(1, Nothing)
        End Sub

    I've commented it just to make life easier for people If they are gonna take a look at this.

    Private Sub Pics_MouseDown(ByVal obj As Object, Sender As Object, e As MouseEventArgs)
    
            'show the menu
            If TankSelectStatus = 1 Then
                TargetSprite = DirectCast(Sender, PictureBox).Name
                TankSelectStatus = 0
                'select the action
                Dim AttackListIndex = GetSpriteIndex(AttackSprite)
                Dim TargetListIndex = GetSpriteIndex(TargetSprite)
                Dim hp As Integer = Sprites(TargetListIndex).HP - Sprites(AttackListIndex).AP
                'popup the menu
                If hp <= 0 Then
                    MsgBox(Sprites(TargetListIndex).Name & " Murked by " & Sprites(AttackListIndex).Name)
                    Sprites(AttackListIndex).HP += Sprites(TargetListIndex).HP
                    'remove sprite from list
                    Sprites(TargetListIndex).Pic.Dispose()
                    Sprites.Remove(Sprites(TargetListIndex))
                Else
                    Sprites(TargetListIndex).HP = Sprites(TargetListIndex).HP - Sprites(AttackListIndex).AP
                    MsgBox("Still standing")
                End If
            Else
                'reset the tools
                AttackSprite = DirectCast(Sender, PictureBox).Name
                TankToolbar.Location = New Point(Sprites(GetSpriteIndex(AttackSprite)).Pic.Right, Sprites(GetSpriteIndex(AttackSprite)).Pic.Bottom)
                TankToolbar.Visible = True
            End If
    
    
            'Fully Operates No Problems with it
            If e.Button = MouseButtons.Left Then
    
                For Each spt As Sprite In Sprites
                    If spt.Pic Is DirectCast(obj, PictureBox) Then
                        If spt.Visible = 2 Then
                            'move the sprite
                            MouseDownPicLocation = spt.Pic.Location
                            MouseDownLocation = e.Location
                            MouseDownSprite = spt
                            spt.Pic.BringToFront()
                        Else
                            'Select the sprite
                            MouseDownSprite = Nothing
                        End If
                        Exit For
                    End If
                Next
            End If
        End Sub



    WRA

    Thursday, March 30, 2017 7:50 PM
  • Hi,

    whats

    Private Sub Pics_MouseDown(ByVal obj As Object, Sender As Object, e As MouseEventArgs)

    ???

    Either sender as Object, or obj as Object, not both, plus the mouseeventargs. Just 2 Parameters

    Private Sub Pics_MouseDown(sender As Object, e As MouseEventArgs)

    Regards,

      Thorsten



    Thursday, March 30, 2017 8:25 PM
  • Hi thanks for pointing that out. when I used the "ByVal Obj as Object" that helps with the case where I want to move the mousebutton to move the sprite around then "Sender As Object" functions well with the tank select feature which chooses which tank to attack. 


    WRA

    Thursday, March 30, 2017 8:26 PM
  • I would still be back at square one because I am still trying to figure out one or the other. I want to assign left mouse button to drag around the sprite and right mouse button to select the sprite. 

    I am thinking what do I do when one is a success while the other isn't?


    WRA

    Thursday, March 30, 2017 8:30 PM
  • I am stuck on this problem at the moment. Could anyone possibly point out where could I be going wrong?

                With pic
                    .Name = Sprites(i).ToString
    

    Unless you have changed the Sprite class, that won't work.  That sort of error suggests that you are not doing adequate testing as you go.

    You have still not provided a clear description of what you expect to happen when the user presses down on a mouse button.

    Thursday, March 30, 2017 8:31 PM
  • I have gone from giving too much information to now way too little information

    WRA

    Thursday, March 30, 2017 8:32 PM
  • BTW the sprite class is the same, nothing there has changed.

                    .Name = "Picturebox" & i.ToString

    The one above is the one I used previously and I used the one you recommended me Acamar

              With pic
                    .Name = Sprites(i).ToString


    WRA

    Thursday, March 30, 2017 8:34 PM
  • Hi thanks for pointing that out. when I used the "ByVal Obj as Object" that helps with the case where I want to move the mousebutton to move the sprite around then "Sender As Object" functions well with the tank select feature which chooses which tank to attack.

    You can't do that.  One parameter, and only one, will refer to the sender.  'obj' and 'sender' are just names - labels provided so your code can refer to the object that is actually being passed in that call. You can't arbitrarily change the signature to suit your code - the signature you provide must match the objects provided by the caller.

    Even if you could make that sort of change, it won't help your problem.  There can only be one sending object for the event handler - the control in which the user clicked.

    You have to use the picture box details to find the tank that occupies that picture box.  That's why you need the tank name in the picture box name property (there are actually better ways to do that, but that's what we are going with for now).

    Thursday, March 30, 2017 8:52 PM
  • The one above is the one I used previously and I used the one you recommended me Acamar

              With pic
                    .Name = Sprites(i).ToString


    I did not recommend that code.

    Thursday, March 30, 2017 8:55 PM
  • Ohh so this wasn't you? Just someone else suggestion

    If you want to use this:

        TargetSprite = DirectCast(sender, PictureBox).Name

    Then you have to change

        With pic
          .Name = "Pic" & i.ToString

    in the form load event to

       With pic
         .Name = Sprites(i).Name


    WRA

    Thursday, March 30, 2017 8:57 PM
  • I have gone from giving too much information to now way too little information

    The information you are providing is as much for your own purposes as it is for others.  By creating a proper description of what you think should happen at that point, you are most of the way towards turning it into code.  The fact that you are confusing people with your descriptions indicates that your own understanding of what you need to do is not clear.  I am sure you have a good picture of how it all should work, but you need to be able to put that picture down as a sequence of logical, precise, non-technical steps before you can create the code that makes it work.

    Thursday, March 30, 2017 9:00 PM
  • Ohh so this wasn't you? Just someone else suggestion

    That's what I recommended.  That's not what you coded.

    Thursday, March 30, 2017 9:02 PM
  • I see so before cutting to the chase with code and stuff give a brief description "In english" of what you want to do before applying code. This is just like the steps with pseudocode.

    WRA

    Thursday, March 30, 2017 9:06 PM
  • I see so before cutting to the chase with code and stuff give a brief description "In english" of what you want to do before applying code. This is just like the steps with pseudocode.

    WRA

    Lets try this simple one form example.

    In form load we make 3 pictureboxes and name them:

    For i = 11 To 13
                'create a picturebox
                Dim pic = New PictureBox()
                With pic
                    Select Case i
                        Case 11
                            .Name = "Picturebox " & i.ToString & ": Roy"
                        Case 12
                            .Name = "Picturebox " & i.ToString & ": George"
                        Case 13
                            .Name = "Picturebox " & i.ToString & ": Billy"
                    End Select

    so the names of the pictureboxes are

            Picturebox 11: Roy
            Picturebox 12: George
            Picturebox 13: Billy

    We name them 11, 12, 13 for convienece because we are using a for loop with those numbers and that is the only easy way to have a unique name for each. To name the pics Roy, George, Billy takes take more code and is not needed.

    Next we make a new class object and add the picturebox to the class object:

              'create a new picex class object
                Dim spt As New PicEX
                'assign the new picturebox to the class object
                spt.Pic = pic

    Now add a reference to the class object in our list:

                'add the new class object reference to the list of class object references
                PicEXList.Add(spt)


    Now assign individual colors and names to the class object. This is not the picturebox name it is the class object which contains the picturebox name.

            PicEXList(0).Name = "PicEx Red"
            PicEXList(0).Pic.BackColor = Color.Red


    Now we have three class objects with pictureboxes:

            PicEX named:"PicEx Red"
                      contains - Picturebox 11: Roy

            PicEX named:"PicEx Green"
                      contains - Picturebox 12: George

            PicEX named: "PicEx Blue"
                      contains - Picturebox 13: Billy
           
    And we have a list with references to the class objects


             list index 0 = PicEX named:"PicEx Red"
             list index 1 = PicEX named:"PicEx Green"
             list index 2 = PicEX named:"PicEx Blue"


    In the mouse down event that we made for all the pictureboxes we are given the SENDER object and the e mouse event arguments. Sender is the picturebox that was clicked. We use DirectCast to get our name for the picturebox from the sender variable.

            Dim thisPictureboxName = DirectCast(Sender, PictureBox).Name

    then we search our list of class objects for the name to get the list index for the object that was clicked

            Dim thisObjectListIndex As Integer = GetSpriteIndex(thisPictureboxName)

    finally we get the names of the various things and show them by clicking a color on the form. We get the name of the class object two ways. The msgbox shows the result.

    So all these possibilities are available to write our code to do what we want.

    Option Strict On
    
    Public Class Form6
        Private Class PicEX
            Public Name As String
            Public Pic As PictureBox
        End Class
        Private PicEXList As New List(Of PicEX)
    
        Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim w As Integer = 50
    
            For i = 11 To 13
                'create a picturebox
                Dim pic = New PictureBox()
                With pic
                    Select Case i
                        Case 11
                            .Name = "Picturebox " & i.ToString & ": Roy"
                        Case 12
                            .Name = "Picturebox " & i.ToString & ": George"
                        Case 13
                            .Name = "Picturebox " & i.ToString & ": Billy"
                    End Select
    
                    .Left = (i - 10) * w
                    .Top = 20
                    .Size = New Size(w, w)
    
                    'add the picturebox to the form
                    Me.Controls.Add(pic)
                    'add the mousedown event handler for the picturebox to the form
                    AddHandler .MouseDown, AddressOf Pics_MouseDown
                End With
    
                'create a new picex class object
                Dim spt As New PicEX
                'assign the new picturebox to the class object
                spt.Pic = pic
                'add the new class object reference to the list of class object references
                PicEXList.Add(spt)
            Next
    
            PicEXList(0).Name = "PicEx Red"
            PicEXList(0).Pic.BackColor = Color.Red
    
            PicEXList(1).Name = "PicEx Green"
            PicEXList(1).Pic.BackColor = Color.Green
    
            PicEXList(2).Name = "PicEx Blue"
            PicEXList(2).Pic.BackColor = Color.Blue
    
        End Sub
        Private Sub Pics_MouseDown(Sender As Object, e As MouseEventArgs)
    
            'get the name of the picturebox that was clicked from the sender
            Dim thisPictureboxName As String = DirectCast(Sender, PictureBox).Name
    
            'get the PicEXList index from the object picturebox name
            Dim thisObjectListIndex As Integer = GetSpriteIndex(thisPictureboxName)
    
            'get the PicEx class object name from the PicEXList index
            Dim thisObjectName1 As String = PicEXList(thisObjectListIndex).Name
    
            'get the PicEX object
            Dim thisObject As PicEX = PicEXList(thisObjectListIndex)
    
            'get the PicEx class object name from the PicEx class object 
            Dim thisObjectName2 As String = thisObject.Name
    
    
            MsgBox(thisPictureboxName & vbLf & thisObjectName1 & vbLf & thisObjectName2)
        End Sub
    
        Private Function GetSpriteIndex(theName As String) As Integer
            For i = 0 To PicEXList.Count - 1
                If theName = PicEXList(i).Pic.Name Then
                    Return i
                End If
            Next
    
            Return -1
        End Function
    End Class

    Edit: changed thisObjectPictureboxName to thisPictureboxName and thisObjectIndex to thisObjectListIndex for clarity.


    PS Wali this example is not exactly the same as what Acamar is suggesting so don't confuse them.

    This is using the same method as the earlier examples I showed you is all. We can change it to Acamars method too. There are many ways to write code to do what you want.




    Friday, March 31, 2017 1:33 PM
  • The one above is the one I used previously and I used the one you recommended me Acamar

              With pic
                    .Name = Sprites(i).ToString


    I did not recommend that code.  I disclaim any responsibility for the result if you continue to use that code.

    Friday, March 31, 2017 7:41 PM
  • Ok. Ill just not use that code above just to play safe and will leave it from there

    WRA

    Saturday, April 1, 2017 11:51 AM
  • @Tommy Thanks for the example Ill take a look at this one and see if it is possible to getting me closer to my solution to the given problem.

    WRA

    Saturday, April 1, 2017 11:54 AM
  • @Tommy & Acamar 

    I finally solved the problem WOOOO. I decided to use instead a double click to use when attacking sprites and the single click to drag the sprites around WOOHOOOOO. 

    Now I can finally move to the next problem which is "range" of sprites which I will announce in the next thread. 

    Thanks again everyone for the help. :)


    WRA

    Monday, April 3, 2017 11:09 AM