Stumped on VB 6.0 LoadPicture function
-
I'm writing a solitaire game and want a specific card in a control array, let's say image1(12) which has a specific picture associated with it, to drop onto a specific position and take over the image of another control array, hearts(12). Here is my code; keep getting file not found. Just using one element in the array right now for testing. Any help would be much appreciated. I'm a noob LOL. Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Hearts(12).Picture = Image1(12).Picture Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Hearts(12).Picture = Source.Picture LoadPicture Image1(12).Picture 'Load Hearts(Index).Picture.ubound + 1 Else: MsgBox ("Your chosen card does not belong here") End If Next End Sub Private Sub Clubs_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Clubs(Index).Picture = Source.Picture End If Next End Sub Private Sub Diamonds_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Diamonds(Index).Picture = Source.Picture End If Next End Sub Private Sub Spades_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Spades(Index).Picture = Source.Picture End If Next End Sub Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) For Index = 0 To 51 If Button = vbLeftButton Then Image1(Index).Drag vbBeginDrag End If Next End Sub Private Sub Image1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) For Index = 0 To 51 If Button = vbLeftButton Then If Image1(Index).Picture = Hearts(Index).Picture Then Image1(Index).Drag vbEndDrag Else: GoTo 5 5 If Image1(Index).Picture = Clubs(Index).Picture Then Image1(Index).Drag vbEndDrag Else: GoTo 9 9 If Image1(Index).Picture = Diamonds(Index).Picture Then Image1(Index).Drag vbEndDrag Else: GoTo 12 12 If Image1(Index).Picture = Spades(Index).Picture Then Image1(Index).Drag vbEndDrag Else: MsgBox ("This card does not match the source card") Image1(Index).Picture = Image1(Index).Picture End If End If En
-
I'm writing a solitaire game and want a specific card in a control array, let's say image1(12) which has a specific picture associated with it, to drop onto a specific position and take over the image of another control array, hearts(12). Here is my code; keep getting file not found. Just using one element in the array right now for testing. Any help would be much appreciated. I'm a noob LOL. Private Sub Hearts_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Hearts(12).Picture = Image1(12).Picture Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Hearts(12).Picture = Source.Picture LoadPicture Image1(12).Picture 'Load Hearts(Index).Picture.ubound + 1 Else: MsgBox ("Your chosen card does not belong here") End If Next End Sub Private Sub Clubs_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Clubs(Index).Picture = Source.Picture End If Next End Sub Private Sub Diamonds_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Diamonds(Index).Picture = Source.Picture End If Next End Sub Private Sub Spades_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) Index = 0 For Index = 0 To 51 If TypeOf Source Is Image Then Spades(Index).Picture = Source.Picture End If Next End Sub Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) For Index = 0 To 51 If Button = vbLeftButton Then Image1(Index).Drag vbBeginDrag End If Next End Sub Private Sub Image1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) For Index = 0 To 51 If Button = vbLeftButton Then If Image1(Index).Picture = Hearts(Index).Picture Then Image1(Index).Drag vbEndDrag Else: GoTo 5 5 If Image1(Index).Picture = Clubs(Index).Picture Then Image1(Index).Drag vbEndDrag Else: GoTo 9 9 If Image1(Index).Picture = Diamonds(Index).Picture Then Image1(Index).Drag vbEndDrag Else: GoTo 12 12 If Image1(Index).Picture = Spades(Index).Picture Then Image1(Index).Drag vbEndDrag Else: MsgBox ("This card does not match the source card") Image1(Index).Picture = Image1(Index).Picture End If End If En
Wow - your code is everything that's bad about VB. Why are you using VB6 for new code ? It's obsolete and unsupported. VB.NET express edition is free, and there's far more help for it. Why are you using VB6, do you hate yourself ?
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
-
Wow - your code is everything that's bad about VB. Why are you using VB6 for new code ? It's obsolete and unsupported. VB.NET express edition is free, and there's far more help for it. Why are you using VB6, do you hate yourself ?
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
LOL, ROFL. That's the only thing I have as far as the program that offers VB 6.0; if Net is free, I can go to that, but I'd have to learn a new language quick; I might be able to swing this; where do you get this, MS site? If so, do you have any idea on what I'm trying to do and can help me in .NET coding? I'd have to change all my code and am happy to post what I have so far, but need to know how to change to .NET. I have until June; in which the game I'm writing is for my Mom's birthday. Any help would be much appreciated. Does .NET have gui too like Visual Basic for MS? IF so, I'd like to use it; if not, then not now, not for this game. I like the visual aspect of it.
-
LOL, ROFL. That's the only thing I have as far as the program that offers VB 6.0; if Net is free, I can go to that, but I'd have to learn a new language quick; I might be able to swing this; where do you get this, MS site? If so, do you have any idea on what I'm trying to do and can help me in .NET coding? I'd have to change all my code and am happy to post what I have so far, but need to know how to change to .NET. I have until June; in which the game I'm writing is for my Mom's birthday. Any help would be much appreciated. Does .NET have gui too like Visual Basic for MS? IF so, I'd like to use it; if not, then not now, not for this game. I like the visual aspect of it.
ymilan wrote:
where do you get this, MS site?
Yes, just google VB.NET Express Edition.
ymilan wrote:
oes .NET have gui too like Visual Basic for MS?
No, .NET has a language and an IDE that leaves VB6 for dead. VB.NET is going to be far easier, and you will get a LOT more help, because people actually use it.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
-
ymilan wrote:
where do you get this, MS site?
Yes, just google VB.NET Express Edition.
ymilan wrote:
oes .NET have gui too like Visual Basic for MS?
No, .NET has a language and an IDE that leaves VB6 for dead. VB.NET is going to be far easier, and you will get a LOT more help, because people actually use it.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
Thanks; I'm trying in Net now and learning; however, I copied some code and am trying it out. I have image1 as the array name of images of cards shuffled on the left. Hearts, Clubs, etc. are the arrays on the right. I'm getting lots of errors. Any help or tutorial pages locations would be great. Trying to shuffle cards right now. Much appreciation in advance. Friend Class Start_Game Inherits System.Windows.Forms.Form Dim Index As Integer Dim value As Integer Dim suit As String Dim picturefront As String Dim position As Integer Dim shuffled As Boolean Private Sub Start_Click() Handles Start.Click Dim count, x As Integer 'sets the actual image1 in suit order used at the start form load For x = 51 To 0 Step -1 _Image1(x).Index = x - -1 Image1(x).suit = "image1" If (x - -1) < 10 Then Image1(x).value = (x - -1) End If If (x - -1) > 10 Then Image1(x).value = 10 End If Next 'Hearts' For x = 52 To 40 Step -1 Hearts(x).Index = (x - 39) Hearts(x).suit = "Hearts" If (x - 39) < 10 Then Hearts(x).value = (x - 39) End If If (x - 39) > 10 Then Hearts(x).value = 10 End If Next x Exit For 'Clubs For x = 39 To 27 Step -1 Clubs(x).Index = (x - 26) Clubs(x).suit = "Clubs" If (x - 26) < 10 Then Clubs(x).value = (x - 26) End If If (x - 26) > 10 Then Clubs(x).value = (10) End If Next x 'Diamonds For x = 26 To 14 Step -1 Diamonds(x).Index = (x - 13) Diamonds(x).suit = "Diamonds" If (x - 13) < 10 Then Diamonds(x).value = (x - 13) End If If (x - 13) > 10 Then Diamonds(x).value = (10) End If Next x 'Spades For x = 13 To 1 Step -1 If x < 10 Then Spades(x).value = x End If If x > 10 Then Spades(x).value = 10 End If Spades(x).Index = x Spades(x).suit = "Spades" Next x For count = 1 To 52 Image1(count).shuffled = False
-
Thanks; I'm trying in Net now and learning; however, I copied some code and am trying it out. I have image1 as the array name of images of cards shuffled on the left. Hearts, Clubs, etc. are the arrays on the right. I'm getting lots of errors. Any help or tutorial pages locations would be great. Trying to shuffle cards right now. Much appreciation in advance. Friend Class Start_Game Inherits System.Windows.Forms.Form Dim Index As Integer Dim value As Integer Dim suit As String Dim picturefront As String Dim position As Integer Dim shuffled As Boolean Private Sub Start_Click() Handles Start.Click Dim count, x As Integer 'sets the actual image1 in suit order used at the start form load For x = 51 To 0 Step -1 _Image1(x).Index = x - -1 Image1(x).suit = "image1" If (x - -1) < 10 Then Image1(x).value = (x - -1) End If If (x - -1) > 10 Then Image1(x).value = 10 End If Next 'Hearts' For x = 52 To 40 Step -1 Hearts(x).Index = (x - 39) Hearts(x).suit = "Hearts" If (x - 39) < 10 Then Hearts(x).value = (x - 39) End If If (x - 39) > 10 Then Hearts(x).value = 10 End If Next x Exit For 'Clubs For x = 39 To 27 Step -1 Clubs(x).Index = (x - 26) Clubs(x).suit = "Clubs" If (x - 26) < 10 Then Clubs(x).value = (x - 26) End If If (x - 26) > 10 Then Clubs(x).value = (10) End If Next x 'Diamonds For x = 26 To 14 Step -1 Diamonds(x).Index = (x - 13) Diamonds(x).suit = "Diamonds" If (x - 13) < 10 Then Diamonds(x).value = (x - 13) End If If (x - 13) > 10 Then Diamonds(x).value = (10) End If Next x 'Spades For x = 13 To 1 Step -1 If x < 10 Then Spades(x).value = x End If If x > 10 Then Spades(x).value = 10 End If Spades(x).Index = x Spades(x).suit = "Spades" Next x For count = 1 To 52 Image1(count).shuffled = False
ymilan wrote:
_Image1(x).Index = x - -1
This looks like you're going to end up with x + 1, x - -1 is x + 1. The best way to shuffle the cards is to get a list from 1 to 52 ( or whatever ). Then create a new list, and put stuff in at random. Assuming that arrays are 0 indexed in VB.NET ( your code seemed to assume they are 1 indexed and I do not know for sure ), you grab a number between 1 and 52 and you remove the number at that index and put it in your new list. Then you grab a number between 1 and 51 ( because you only have 51 left to shuffle, right ?) and grab the number at that index and push it into your new list. Go all the way down, and you will have a shuffled deck.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
-
ymilan wrote:
_Image1(x).Index = x - -1
This looks like you're going to end up with x + 1, x - -1 is x + 1. The best way to shuffle the cards is to get a list from 1 to 52 ( or whatever ). Then create a new list, and put stuff in at random. Assuming that arrays are 0 indexed in VB.NET ( your code seemed to assume they are 1 indexed and I do not know for sure ), you grab a number between 1 and 52 and you remove the number at that index and put it in your new list. Then you grab a number between 1 and 51 ( because you only have 51 left to shuffle, right ?) and grab the number at that index and push it into your new list. Go all the way down, and you will have a shuffled deck.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )