Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB6 card game question

VB6 card game question

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasegame-devdata-structures
24 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R riced

    I don't think you want to be doing this. When you drag a card from the left (i.e. image1(x)) to right, when the dragged card enters the Hearts() area then Hearts_DragOver is triggered. At this point you should only be doing something like changing the Hearts background to give visual indication to the user; and restoring original background if state = 1. You should not be changing the image to that of the card you have dragged - that should be done in Hearts_DragDrop. The state variable only tells you if you are entering (0), leaving (1) or moving within (2) the target area. So when state=0 and the user releases the mouse button, a Hearts_DragDrop event is triggered - it's in that event that you would want to change the image.

    Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

    Y Offline
    Y Offline
    ymilan
    wrote on last edited by
    #13

    Thank you; so this code wouldn't work then?   I thought I had it close, but get a runtime error of 340.   So, I'll take heed of your suggestion though; back to the drawing board.   Thanks in advance. Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Dim NewIndex As Integer 'For Index = 0 To 12       'If TypeOf Source Is Image Then          ' Hearts(Index).Picture = Source.Picture       'End If 'Next Index = 0 NewIndex = 0 For Index = 0 To 12 For NewIndex = 0 To 12       Image1(Index).Picture = Hearts(NewIndex).Picture       Index = Index + 1       NewIndex = NewIndex + 1 Next Next For Index = 0 To 12 For NewIndex = 0 To 12       If Image1(Index).Picture = Hearts(NewIndex).Picture Then             Image1(Index).Drag vbEndDrag             MsgBox ("You're right!")       Exit Sub       Else             Image1(Index).Drag vbCancel             MsgBox ("This card does not belong here")       Exit Sub       End If Next Next End Sub

    1 Reply Last reply
    0
    • R riced

      I don't think you want to be doing this. When you drag a card from the left (i.e. image1(x)) to right, when the dragged card enters the Hearts() area then Hearts_DragOver is triggered. At this point you should only be doing something like changing the Hearts background to give visual indication to the user; and restoring original background if state = 1. You should not be changing the image to that of the card you have dragged - that should be done in Hearts_DragDrop. The state variable only tells you if you are entering (0), leaving (1) or moving within (2) the target area. So when state=0 and the user releases the mouse button, a Hearts_DragDrop event is triggered - it's in that event that you would want to change the image.

      Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

      Y Offline
      Y Offline
      ymilan
      wrote on last edited by
      #14

      I'm a bit still confused; you think I should use dragover?   dragdrop seems to allow me to drag and drop the cards just fine.   Problem is I don't know how to write the code for this....what you are stating....I know State is for dragover, but if I don't use that, I use source for dragdrop.   Now I don't even know the right settings for the cards on the left and on the right for in design mode, dragmode, oledragdrop, and oledrag...something, can't remember off the top of my head.   But now I have all those confused and that's what might be causing my code not to work properly.   Can you pleeeeeese help?   You're my only hope.

      R 1 Reply Last reply
      0
      • R riced

        I don't think you want to be doing this. When you drag a card from the left (i.e. image1(x)) to right, when the dragged card enters the Hearts() area then Hearts_DragOver is triggered. At this point you should only be doing something like changing the Hearts background to give visual indication to the user; and restoring original background if state = 1. You should not be changing the image to that of the card you have dragged - that should be done in Hearts_DragDrop. The state variable only tells you if you are entering (0), leaving (1) or moving within (2) the target area. So when state=0 and the user releases the mouse button, a Hearts_DragDrop event is triggered - it's in that event that you would want to change the image.

        Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

        Y Offline
        Y Offline
        ymilan
        wrote on last edited by
        #15

        Oh in addition, what I need to know is what setting, manual, automatic, or none do I set in design view for the one dragmode, and two oledrag properties?

        1 Reply Last reply
        0
        • R riced

          I don't think you want to be doing this. When you drag a card from the left (i.e. image1(x)) to right, when the dragged card enters the Hearts() area then Hearts_DragOver is triggered. At this point you should only be doing something like changing the Hearts background to give visual indication to the user; and restoring original background if state = 1. You should not be changing the image to that of the card you have dragged - that should be done in Hearts_DragDrop. The state variable only tells you if you are entering (0), leaving (1) or moving within (2) the target area. So when state=0 and the user releases the mouse button, a Hearts_DragDrop event is triggered - it's in that event that you would want to change the image.

          Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

          Y Offline
          Y Offline
          ymilan
          wrote on last edited by
          #16

          This is what I've tried as well....still in design mode I have each image1 card set to Manual for dragmode, Automatic for oledragmode and automatic for oledropmode.   Not sure what to set the hearts cards to though...tried many different modes and all seems confusing...here is my code so far:   Wondering if I should have the question of whether image1(1 through 12) = Hearts(1 through 12) in the dragdrop not dragover....I tried that too, but no avail. Public Sub Image1_Click(Index As Integer) For Index = 0 To 12       Hearts(Index).Picture = Image1(Index).Picture Next Index For Index = 13 To 25       Clubs(Index).Picture = Image1(Index).Picture Next Index For Index = 26 To 38       Diamonds(Index).Picture = Image1(Index).Picture Next Index For Index = 39 To 51       Spades(Index).Picture = Image1(Index).Picture Next Index End Sub Private Sub Hearts_DragOver(Index As Integer, Source As Control, _       X As Single, Y As Single, State As Integer) For Index = 0 To 12       If State = vbEnter Then             If Source.Picture = Image1(Index).Picture Then                   If Image1(Index).Picture = Hearts(Index).Picture Then                         Image1(Index).Drag vbEndDrag                         MsgBox ("You're Right")                   Exit Sub                   Else                         Image1(Index).Drag vbCancel                         MsgBox ("You're Wrong")                   Exit Sub                   End If             End If       End If Next Index    End Sub Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) For Index = 0 To 12       Hea

          1 Reply Last reply
          0
          • Y ymilan

            I'm a bit still confused; you think I should use dragover?   dragdrop seems to allow me to drag and drop the cards just fine.   Problem is I don't know how to write the code for this....what you are stating....I know State is for dragover, but if I don't use that, I use source for dragdrop.   Now I don't even know the right settings for the cards on the left and on the right for in design mode, dragmode, oledragdrop, and oledrag...something, can't remember off the top of my head.   But now I have all those confused and that's what might be causing my code not to work properly.   Can you pleeeeeese help?   You're my only hope.

            R Offline
            R Offline
            riced
            wrote on last edited by
            #17

            ymilan wrote:

            you think I should use dragover?

            Not for dropping the image. As I said you should only be changing something like the background or border of the target to give user feedback. If you don't want to give feedback do nothing. To see why imagine you have a form with four images. On the left is an image called theShape; on the right are three images called BoxA, BoxB and BoxC. Imagine that the user selects theShape image and drags it to the right of the form (i.e.they are holding the mouse button down). Suppose they drag the shape over the BoxA image. This will trigger the BoxA_DragOver event with state = 0. What should this event do? One option is nothing, so you don't write any code for the event. Another option is to change the border or color of the BoxA image so the user knows that theShape is over BoxA. What you should not do is set BoxA image to theShape image. The user has not released the mouse button so they don't want theShape to be in BoxA. If the user does release the mouse button then the BoxA_DragDrop event is triggered. That is when you might want to set BoxA image to theShape so that the code to do so should be in the BoxA_DragDrop event. Suppose the user drags theShape over the BoxA image (without releasing the mouse button) and then drags it over the BoxB image. Two things happen. First the BoxA_DragOver event is triggered with state = 1; then the BoxB_DragOver event is triggered with state = 0. In this case the BoxA_DragDrop could set the border or color back to their original values and the BoxB_DragDrop could change the border or color of BoxB image. Again, BoxB_DragOver should not set the BoxB image to theShape image. The user might continue the drag so it goes over BoxC. If you imagine that the images for the boxes are much larger than theShape image, then as the user drags theShape around in a box image the DragOver event is triggered continuously with state = 2. In most cases that does not matter so the code does nothing. This all means that the typical code for a DragOver event will be something like:

            If State = 0 Then
            'Do something like change border or color of the box
            'You simply want to make user aware of where theShape has been dragged too
            Else
            If State = 1 Then
            'Set the border/color of the box back to original value
            Else 'State = 2
            'Do nothing - they are moving around within the box
            End If
            End If

            Regards David R ------

            Y 2 Replies Last reply
            0
            • R riced

              ymilan wrote:

              you think I should use dragover?

              Not for dropping the image. As I said you should only be changing something like the background or border of the target to give user feedback. If you don't want to give feedback do nothing. To see why imagine you have a form with four images. On the left is an image called theShape; on the right are three images called BoxA, BoxB and BoxC. Imagine that the user selects theShape image and drags it to the right of the form (i.e.they are holding the mouse button down). Suppose they drag the shape over the BoxA image. This will trigger the BoxA_DragOver event with state = 0. What should this event do? One option is nothing, so you don't write any code for the event. Another option is to change the border or color of the BoxA image so the user knows that theShape is over BoxA. What you should not do is set BoxA image to theShape image. The user has not released the mouse button so they don't want theShape to be in BoxA. If the user does release the mouse button then the BoxA_DragDrop event is triggered. That is when you might want to set BoxA image to theShape so that the code to do so should be in the BoxA_DragDrop event. Suppose the user drags theShape over the BoxA image (without releasing the mouse button) and then drags it over the BoxB image. Two things happen. First the BoxA_DragOver event is triggered with state = 1; then the BoxB_DragOver event is triggered with state = 0. In this case the BoxA_DragDrop could set the border or color back to their original values and the BoxB_DragDrop could change the border or color of BoxB image. Again, BoxB_DragOver should not set the BoxB image to theShape image. The user might continue the drag so it goes over BoxC. If you imagine that the images for the boxes are much larger than theShape image, then as the user drags theShape around in a box image the DragOver event is triggered continuously with state = 2. In most cases that does not matter so the code does nothing. This all means that the typical code for a DragOver event will be something like:

              If State = 0 Then
              'Do something like change border or color of the box
              'You simply want to make user aware of where theShape has been dragged too
              Else
              If State = 1 Then
              'Set the border/color of the box back to original value
              Else 'State = 2
              'Do nothing - they are moving around within the box
              End If
              End If

              Regards David R ------

              Y Offline
              Y Offline
              ymilan
              wrote on last edited by
              #18

              Awesome!   I understand dragover now!   I will write that and see how I do.   However, please assist on dragdrop; what do I put in that code?   I tried hearts(index).Picture = Source, like every tutorial I read said to do.   Then do I do vbenddrag and vbcancel like I did before, or is this in error?

              1 Reply Last reply
              0
              • R riced

                ymilan wrote:

                you think I should use dragover?

                Not for dropping the image. As I said you should only be changing something like the background or border of the target to give user feedback. If you don't want to give feedback do nothing. To see why imagine you have a form with four images. On the left is an image called theShape; on the right are three images called BoxA, BoxB and BoxC. Imagine that the user selects theShape image and drags it to the right of the form (i.e.they are holding the mouse button down). Suppose they drag the shape over the BoxA image. This will trigger the BoxA_DragOver event with state = 0. What should this event do? One option is nothing, so you don't write any code for the event. Another option is to change the border or color of the BoxA image so the user knows that theShape is over BoxA. What you should not do is set BoxA image to theShape image. The user has not released the mouse button so they don't want theShape to be in BoxA. If the user does release the mouse button then the BoxA_DragDrop event is triggered. That is when you might want to set BoxA image to theShape so that the code to do so should be in the BoxA_DragDrop event. Suppose the user drags theShape over the BoxA image (without releasing the mouse button) and then drags it over the BoxB image. Two things happen. First the BoxA_DragOver event is triggered with state = 1; then the BoxB_DragOver event is triggered with state = 0. In this case the BoxA_DragDrop could set the border or color back to their original values and the BoxB_DragDrop could change the border or color of BoxB image. Again, BoxB_DragOver should not set the BoxB image to theShape image. The user might continue the drag so it goes over BoxC. If you imagine that the images for the boxes are much larger than theShape image, then as the user drags theShape around in a box image the DragOver event is triggered continuously with state = 2. In most cases that does not matter so the code does nothing. This all means that the typical code for a DragOver event will be something like:

                If State = 0 Then
                'Do something like change border or color of the box
                'You simply want to make user aware of where theShape has been dragged too
                Else
                If State = 1 Then
                'Set the border/color of the box back to original value
                Else 'State = 2
                'Do nothing - they are moving around within the box
                End If
                End If

                Regards David R ------

                Y Offline
                Y Offline
                ymilan
                wrote on last edited by
                #19

                Ok, this is the code I have so far, but ALL the cards from every suit are allowed to drop on the target.   In design view, I need some assistance on whether to put Manual, Autmatic, or None or DragDrop, OLEDragOver, OLEDragDrop.....I think that may be messing this whole thing up.   Anyhow, my code is below; any errors? Private Sub Hearts_DragOver(Index As Integer, Source As Control, _       X As Single, Y As Single, State As Integer) For Index = 0 To 12       If State = 0 Then             CommonDialog1.Flags = &H80FFFF             CommonDialog1.ShowColor             Hearts(Index).BackColor = CommonDialog1.Color       Else       If State = 1 Then             CommonDialog1.Flags = &HFFFFFF             CommonDialog1.ShowColor             Hearts(Index).BackColor = CommonDialog1.Color       Else       If State = 2 Then       End If       End If       End If Next Index End Sub Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) For Index = 0 To 12       Hearts(Index).Picture = Source.Picture       Source.Picture = Image1(Index).Picture Next Index    For Index = 0 To 12       If Image1(Index).Picture = Hearts(Index).Picture Then       Image1(Index).DragMode Manual       Image1(Index).Drag vbEndDrag       MsgBox ("You're Right")       Else       Image1(Index).Drag vbCancel       MsgBox ("You're Wrong")       End If Next Index

                R 1 Reply Last reply
                0
                • Y ymilan

                  Ok, this is the code I have so far, but ALL the cards from every suit are allowed to drop on the target.   In design view, I need some assistance on whether to put Manual, Autmatic, or None or DragDrop, OLEDragOver, OLEDragDrop.....I think that may be messing this whole thing up.   Anyhow, my code is below; any errors? Private Sub Hearts_DragOver(Index As Integer, Source As Control, _       X As Single, Y As Single, State As Integer) For Index = 0 To 12       If State = 0 Then             CommonDialog1.Flags = &H80FFFF             CommonDialog1.ShowColor             Hearts(Index).BackColor = CommonDialog1.Color       Else       If State = 1 Then             CommonDialog1.Flags = &HFFFFFF             CommonDialog1.ShowColor             Hearts(Index).BackColor = CommonDialog1.Color       Else       If State = 2 Then       End If       End If       End If Next Index End Sub Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) For Index = 0 To 12       Hearts(Index).Picture = Source.Picture       Source.Picture = Image1(Index).Picture Next Index    For Index = 0 To 12       If Image1(Index).Picture = Hearts(Index).Picture Then       Image1(Index).DragMode Manual       Image1(Index).Drag vbEndDrag       MsgBox ("You're Right")       Else       Image1(Index).Drag vbCancel       MsgBox ("You're Wrong")       End If Next Index

                  R Offline
                  R Offline
                  riced
                  wrote on last edited by
                  #20

                  Firstly, I don't think you should be messing with OLEDrag* at all, so would set OLEDragMode property to 0. OLE drag features are for dragging and dropping data rather than images. E.g. drag data between DataGrid controls. Secondly, I don't think you should have loops in the Hearts_DragOver or Hearts_DragDrop events. You probably should not be changing the value of Index (as the loops are doing) and I doubt that you should be changing the Source.Picture. Imagine the following. There is a form with two control arrays called theShapes and theBoxes. Both have say 5 items (so indexes go from 0 to 4) with theShapes on left of form; theBoxes on right. The user clicks and drags e.g. theShapes(3) image over to the right. Suppose it is dragged over theBoxes(1) image. Then the theBoxes_DragOver event is triggered with Index = 1 and State = 0. So in the code the only image that should change color is theBoxes(1). All the other theBoxes() images should remain as they were. So no loop required. Also, the Source is theShapes(3) and presumably you don't want its picture to change. So you never want to be doing something like Source.Picture = SomeOtherControl.Picture. Suppose that the object is to place the correct shapes in the correct boxes. So at the start theBoxes() all have some blank image; theShapes() all have some appropriate image. E.g. theShapes(3) could be a triangle, theShapes(4) could be a circle, etc. If the user drags a shape and drops it into a box, the box should only accept it if it is the correct shape. So e.g. if theShape(3) (i.e. a triangle) is dragged and dropped into theBoxes(1), the drop should only succeed if theBoxes(1) accepts triangles. So how do we tell if this is the case? We cannot compare pictures because theBoxes() are all a blank image so will never be the same as a shape image. One way of doing this is to set the Tag property for each of the controls and compare the Tags before allowing the drop to succeed or fail. E.g. when setting up the control arrays you would have something like

                  theShapes(3).Tag = "Triangle"
                  theBoxes(0).Tag = "Square"
                  theBoxes(1).Tag = "Triangle"
                  theBoxes(2).Tag = "Circle"

                  In the theBoxes_DragDrop event you would then have something like

                  If theBoxes(Index).Tag = Source.Tag Then
                  'Allow the drop
                  Else
                  'Cancel the drop
                  End If

                  I think this is how to do it. But to do so requires that the DragMode for theShapes() to be set to 0 (i.e. vbManual) and that the Drag method is implemented. I might b

                  Y 1 Reply Last reply
                  0
                  • R riced

                    Firstly, I don't think you should be messing with OLEDrag* at all, so would set OLEDragMode property to 0. OLE drag features are for dragging and dropping data rather than images. E.g. drag data between DataGrid controls. Secondly, I don't think you should have loops in the Hearts_DragOver or Hearts_DragDrop events. You probably should not be changing the value of Index (as the loops are doing) and I doubt that you should be changing the Source.Picture. Imagine the following. There is a form with two control arrays called theShapes and theBoxes. Both have say 5 items (so indexes go from 0 to 4) with theShapes on left of form; theBoxes on right. The user clicks and drags e.g. theShapes(3) image over to the right. Suppose it is dragged over theBoxes(1) image. Then the theBoxes_DragOver event is triggered with Index = 1 and State = 0. So in the code the only image that should change color is theBoxes(1). All the other theBoxes() images should remain as they were. So no loop required. Also, the Source is theShapes(3) and presumably you don't want its picture to change. So you never want to be doing something like Source.Picture = SomeOtherControl.Picture. Suppose that the object is to place the correct shapes in the correct boxes. So at the start theBoxes() all have some blank image; theShapes() all have some appropriate image. E.g. theShapes(3) could be a triangle, theShapes(4) could be a circle, etc. If the user drags a shape and drops it into a box, the box should only accept it if it is the correct shape. So e.g. if theShape(3) (i.e. a triangle) is dragged and dropped into theBoxes(1), the drop should only succeed if theBoxes(1) accepts triangles. So how do we tell if this is the case? We cannot compare pictures because theBoxes() are all a blank image so will never be the same as a shape image. One way of doing this is to set the Tag property for each of the controls and compare the Tags before allowing the drop to succeed or fail. E.g. when setting up the control arrays you would have something like

                    theShapes(3).Tag = "Triangle"
                    theBoxes(0).Tag = "Square"
                    theBoxes(1).Tag = "Triangle"
                    theBoxes(2).Tag = "Circle"

                    In the theBoxes_DragDrop event you would then have something like

                    If theBoxes(Index).Tag = Source.Tag Then
                    'Allow the drop
                    Else
                    'Cancel the drop
                    End If

                    I think this is how to do it. But to do so requires that the DragMode for theShapes() to be set to 0 (i.e. vbManual) and that the Drag method is implemented. I might b

                    Y Offline
                    Y Offline
                    ymilan
                    wrote on last edited by
                    #21

                    Wow!   Thanks for the expert explanation.   Does this mean I would put: Image1(0).Tag = Hearts(0).Tag Somewhere in the first part of the code?   Where so?   This is all my code so far; problem is which ever card is in the first slot (as in Image1(0)), but can be any card, when dropped over Hearts(0), it says, you're right and allows drop.   If the real Image1(0).Picture, King Hearts is dropped over Hearts(0), it says you're wrong. I changed all my settings in design mode to put images on the left as Automatic and none for both OLE modes.   I set images on the right to be Manual for drag and none for both Ole modes.   Any problems on this?   Here is all of my code so far:   I appeciate your help.... Option Explicit Public Sub Main()       Start_Game.Show End Sub Private Sub Exit_Click()       MsgBox ("Thank you for playing.   Good Bye.") End End Sub Private Sub Start_Click()       Dim arrDeck(52)       Dim Cardcount As Integer       Dim Counter As Integer Do While Cardcount <= 51       arrDeck(Cardcount) = Cardcount       Cardcount = Cardcount + 1 Loop Dim swap As Integer Dim posn1 As Integer Dim posn2 As Integer Randomize       For swap = 0 To 100             posn1 = Int(52 * Rnd)             posn2 = Int(52 * Rnd)             If (posn1 <> posn2) Then                   KingH(0).Picture = Image1(posn1).Picture                   Image1(posn1).Picture = Image1(posn2).Picture                   Image1(posn2).Picture = KingH(0).Picture             End If       Next swap Counter = 0 For Counter = 0 To 51       Image1(Counter).Visible = True Next Counter End Sub Private Sub Hearts_DragOver(Index As Integer, Source As Control, _       X As Single, Y As Single, State As Integer) If Index <= 12 Then       If State = 0 Then          &n

                    R 1 Reply Last reply
                    0
                    • Y ymilan

                      Wow!   Thanks for the expert explanation.   Does this mean I would put: Image1(0).Tag = Hearts(0).Tag Somewhere in the first part of the code?   Where so?   This is all my code so far; problem is which ever card is in the first slot (as in Image1(0)), but can be any card, when dropped over Hearts(0), it says, you're right and allows drop.   If the real Image1(0).Picture, King Hearts is dropped over Hearts(0), it says you're wrong. I changed all my settings in design mode to put images on the left as Automatic and none for both OLE modes.   I set images on the right to be Manual for drag and none for both Ole modes.   Any problems on this?   Here is all of my code so far:   I appeciate your help.... Option Explicit Public Sub Main()       Start_Game.Show End Sub Private Sub Exit_Click()       MsgBox ("Thank you for playing.   Good Bye.") End End Sub Private Sub Start_Click()       Dim arrDeck(52)       Dim Cardcount As Integer       Dim Counter As Integer Do While Cardcount <= 51       arrDeck(Cardcount) = Cardcount       Cardcount = Cardcount + 1 Loop Dim swap As Integer Dim posn1 As Integer Dim posn2 As Integer Randomize       For swap = 0 To 100             posn1 = Int(52 * Rnd)             posn2 = Int(52 * Rnd)             If (posn1 <> posn2) Then                   KingH(0).Picture = Image1(posn1).Picture                   Image1(posn1).Picture = Image1(posn2).Picture                   Image1(posn2).Picture = KingH(0).Picture             End If       Next swap Counter = 0 For Counter = 0 To 51       Image1(Counter).Visible = True Next Counter End Sub Private Sub Hearts_DragOver(Index As Integer, Source As Control, _       X As Single, Y As Single, State As Integer) If Index <= 12 Then       If State = 0 Then          &n

                      R Offline
                      R Offline
                      riced
                      wrote on last edited by
                      #22

                      ymilan wrote:

                      put images on the left as Automatic and

                      Then you cannot stop the drop - you can only do that if the mode is Manual and you have a Drag method which allows you to Cancel the drop.

                      ymilan wrote:

                      If State = 0 Then Hearts(Index).Picture = LoadPicture("C:\Program1\redbacking.gif") Else If State = 1 Then Hearts(Index).Picture = Hearts(Index).Picture Else

                      This won't work - when you DragDrop is triggered with State = 0 (entering) the Hearts(Index).Picture is changed to the gif. When it is triggered with state = 1 (leaving) it set back to itself i.e. to the gif it was set to when entering.

                      ymilan wrote:

                      Does this mean I would put: Image1(0).Tag = Hearts(0).Tag Somewhere in the first part of the code?

                      Have you set Hearts(x).Tags in Designer for all controls? If so and you want the Image(x).Tags to be the same as the Hearts(x) tags, you need to do so in the Form_Load event. But I'm not sure that's what you want. Is this the complete code? There seems to be something missing e.g. this is not right.

                      ymilan wrote:

                      Private Sub Exit_Click() MsgBox ("Thank you for playing. Good Bye.") End End Sub

                      Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

                      Y 2 Replies Last reply
                      0
                      • R riced

                        ymilan wrote:

                        put images on the left as Automatic and

                        Then you cannot stop the drop - you can only do that if the mode is Manual and you have a Drag method which allows you to Cancel the drop.

                        ymilan wrote:

                        If State = 0 Then Hearts(Index).Picture = LoadPicture("C:\Program1\redbacking.gif") Else If State = 1 Then Hearts(Index).Picture = Hearts(Index).Picture Else

                        This won't work - when you DragDrop is triggered with State = 0 (entering) the Hearts(Index).Picture is changed to the gif. When it is triggered with state = 1 (leaving) it set back to itself i.e. to the gif it was set to when entering.

                        ymilan wrote:

                        Does this mean I would put: Image1(0).Tag = Hearts(0).Tag Somewhere in the first part of the code?

                        Have you set Hearts(x).Tags in Designer for all controls? If so and you want the Image(x).Tags to be the same as the Hearts(x) tags, you need to do so in the Form_Load event. But I'm not sure that's what you want. Is this the complete code? There seems to be something missing e.g. this is not right.

                        ymilan wrote:

                        Private Sub Exit_Click() MsgBox ("Thank you for playing. Good Bye.") End End Sub

                        Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

                        Y Offline
                        Y Offline
                        ymilan
                        wrote on last edited by
                        #23

                        Can I have your email address again to take this offline?   I have some gifs to show you. Thanks. YMilan

                        1 Reply Last reply
                        0
                        • R riced

                          ymilan wrote:

                          put images on the left as Automatic and

                          Then you cannot stop the drop - you can only do that if the mode is Manual and you have a Drag method which allows you to Cancel the drop.

                          ymilan wrote:

                          If State = 0 Then Hearts(Index).Picture = LoadPicture("C:\Program1\redbacking.gif") Else If State = 1 Then Hearts(Index).Picture = Hearts(Index).Picture Else

                          This won't work - when you DragDrop is triggered with State = 0 (entering) the Hearts(Index).Picture is changed to the gif. When it is triggered with state = 1 (leaving) it set back to itself i.e. to the gif it was set to when entering.

                          ymilan wrote:

                          Does this mean I would put: Image1(0).Tag = Hearts(0).Tag Somewhere in the first part of the code?

                          Have you set Hearts(x).Tags in Designer for all controls? If so and you want the Image(x).Tags to be the same as the Hearts(x) tags, you need to do so in the Form_Load event. But I'm not sure that's what you want. Is this the complete code? There seems to be something missing e.g. this is not right.

                          ymilan wrote:

                          Private Sub Exit_Click() MsgBox ("Thank you for playing. Good Bye.") End End Sub

                          Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

                          Y Offline
                          Y Offline
                          ymilan
                          wrote on last edited by
                          #24

                          When I put the images on the left in design view as automatic, when they are in a random place, i.e. image1(0), King of Hearts, they do not move at all.   When I put them in manual, they move. For some reason; and you said; but I don't understand the reason; when in State 0, I move the images, i.e. King of Hearts to the top of the hearts(0) image (a white backing gif, not King of Hearts.   I did this so I can show a white backed card, so the player can see a white card instead of a black space.   I can place the redbacking card no problem when the card enters the white backed card on the right.   It works.   However, if it is right, it doesn't drop the Image1(Index).Picture at all.   It leaves it a redbacking gif. Now, when my images on the left are randomized, and I want to pic out the King of Hearts on the left, somewhere in the shuffle, it says you're wrong when I place it over the hearts(0) position on the right.   It shows a red backing but, does not say You're right or drop the card.   I have that code in my hearts dragdrop; you'll see above in my last code reply.   However, when I place a random card from the Image1(0) POSITION on the left, it works and says you'r right, but that is the wrong card....????   Don't understand.   It leaves a redbacked gif as well, when it is the wrong card, but say's your're right. You're helping me and I'm glad;   Thank you.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups