Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.18 / 5.00 3,534 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.80 / 5.00 4,200 ViewsThis is probably an easy question to answer, but I can't seem to to do it on my own
basically, I want to create a new pictureBox and place it where a button was, but the pictureBox will not show up.
I'm not used to the code html yet, so this might look screwed up
Dim picNewX As New PictureBox
picNewX.Width = 77
picNewX.Height = 62
picNewX.Image = picX.Image
picNewX.Visible = True
picNewX.Show()
picNewX.Location = btnOneTwo.Location The picturebox needs to know its parent, just add this line in your code.
picNewX.Parent = Me
This was my guess as to what you wanted. Needless to say my naming conventions are terrible and should not be replicated.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim picBox As New PictureBox
picBox.Width = 100
picBox.Height = 100
picBox.Image = Nothing 'add your image
picBox.Parent = Me '//IMPORTANT, otherwise the picture box doesn't know where to go
picBox.BorderStyle = BorderStyle.Fixed3D '// testing: see the picture box without image
picBox.Show()
picBox.Location = Button1.Location
Button1.Visible = False
End Sub thanks, I ended up using a different method to get the images to work though.
But I hit another weird issue
Basically, I'm making a game of tic tac toe, and what happens is that when you click a button, it adds a value to an int variable that determines if it was you or the computer who made the move, you put in 1 and the computer puts in 2 (such as intOneOne = 1 means that you clicks the top left button to place your x, where the computer uses o)
Bit there is a funky error in the AI. what it does is that the ai picks a box you haven't picked, but if it picks 3, it also selects another box at random without giving that box the proper value of 2
see anything wrong in the code? intRandomPick is a number between 0 and 8
While blnStop = False
If intRandomPick = 0 And intOneOne = 0 Then
intOneOne = intOneOne + 2
picOOneOne.Visible = True
btnOneOne.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 1 And intOneTwo = 0 Then
intOneTwo = intOneTwo + 2
picOOneTwo.Visible = True
btnOneTwo.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 2 And intOneThree = 0 Then
intOneThree = intOneThree + 2
picOOneThree.Visible = True
btnOneThree.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 3 And intTwoOne = 0 Then
intTwoOne = intTwoOne + 2
picOTwoOne.Visible = True
btnTwoOne.Visible = False
blnStop = False
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 4 And intTwoTwo = 0 Then
intTwoTwo = intTwoTwo + 2
picOTwoTwo.Visible = True
btnTwoTwo.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 5 And intTwoThree = 0 Then
intTwoThree = intTwoThree + 2
picOTwoThree.Visible = True
btnTwoThree.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 6 And intThreeOne = 0 Then
intThreeOne = intThreeOne + 2
picOThreeOne.Visible = True
btnThreeOne.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 7 And intThreeTwo = 0 Then
intThreeTwo = intThreeTwo + 2
picOThreeTwo.Visible = True
btnThreeTwo.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
ElseIf intRandomPick = 8 And intThreeThree = 0 Then
intThreeThree = intThreeThree + 2
picOThreeThree.Visible = True
btnThreeThree.Visible = False
blnStop = True
intDrawCollective = intDrawCollective + 1
WinTest()
Else
intRandomPick = randChoice.Next(9)
End If
End While ok, nevermind, the other random button selected when 3 is does give that slot's variable the proper number
nevermind as in the 3 thing is still a problem, but that isn't
I'm going to need to see the entire programme in order to help you better. You can zip it up and PM me/post it here if you would like.
That while loop looks very suspect to me, but I can't really say until I see this code in a clearer context.
Under Else if 3:
blnStop = False
should be
blnStop = True
At 5/3/12 02:15 PM, nameistaken1 wrote: Under Else if 3:
blnStop = False
should be
blnStop = True
Ah, nice catch.