Making An Array Of Pictureboxes At Runtime?
May 22, 2010
im making an array of pictureboxes at runtime:
Dim picEnemy(9) As PictureBox
Dim enemysprite As Image
enemysprite = Image.FromFile("....gif")
[Code]....
i get the error:Object reference not set to an instance of an object.
now i know the error would be solved if i had:
dim picEnemy as New Picturebox, but i cant since its an array
View 3 Replies
ADVERTISEMENT
Mar 5, 2009
im doing a project in which im basically trying to make an etch-a-sketch style program.
I am using a 5x5 pixel picture box as the 'cursor' and have made the program so that i can move the picture box with the arrow keys. I am currently trying to work out how to make a trail of identical picture boxes (from an array of picture boxes) appear wherever the cursor has been using this code
Case Keys.Left
CurrentLoc = New Point(PictureBox1.Location.X, PictureBox1.Location.Y)
If Not PictureBox1.Location.X - 5 < 0 Then
[Code]....
Basically, im trying to make a trail by moving the original picturebox and the inserting an identical picturebox in the original's previous position. However, the new identical ones do not display
View 3 Replies
Oct 14, 2010
Having created my picture boxes at runtime, I am able to drag and drop them, but I have a few technical problems. After a few days of 'playing' seem to be going around in circles.There are three main problems:-
1. The last picturebox created is the only one I can drag.
I tried using "CType(sender,PicBox)" but never got it to work successfully.
2. The picturebox moves to the mouse cursor whenever I click it.
3. There seems to be an offset from where the cursor actually is, to where the picturebox actually moves.
Heres what I have so far.
Private Sub BtnRepeatCubDes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRepeatCubDes.Click
Try
intPicBoxCount += 1
ReDim PicBoxes(100)
[code]....
View 3 Replies
Jun 23, 2012
I trying to add to picturebox to a panel, the idea is to add an unknown aamount of pctureboxes to a scrollable panel. For now im just trying to add 1.
Dim PB As New PictureBox
With PB
.Name = "MyPic"
[Code]....
View 1 Replies
Apr 16, 2010
I have code my pictureboxes so that I can move them around my form, however i can move a picturebox under another picturebox. Basically What i would like to be able to do it for a picturebox not to be able to go underneath another picturebox and thus dissapear.For example my picturebox 1 when i move it can go under my picturebox2, I would like it to touch the edges of picturebox2 at most but not go underneath it. I am using visual basic 2008.
View 4 Replies
Oct 18, 2011
I have successfully randomized certain pictureboxes in a grid to contain mines, and show that mine, and for testing purposes, those mines are currently showing. What do you think I need to do to be able to say[code]...
View 3 Replies
Dec 13, 2010
So basically, i have successfully randomized certain pictureboxes in a grid to containmines, and show that mine, and for testing purposes, those mines are currently showing. What do you think I need to do to be able to say:
View 1 Replies
Jun 25, 2008
Recently I have been wanting to learn a bit more about Visual Basic and I've decided that I want to test my abilities by Making a Card game. The card game uses a customized deck of around 140 card. The Cards are all buildings which you need to place down by discarding a specific amount of cards in yoiur hand. The Objective of the game is to get 12 buildings built and get the most points. Many cards will be layed down at some point in the game.The way I think I will be creating the game is by Creating a Class for the Deck which will use a class for the Card. I would like the Card Class to somehow create a picture box of the cards image on the form which will hold all the other cards being displayed.
View 3 Replies
Apr 22, 2011
I am making a 2D game that has a player (me) that shoots bullets (pictureboxes) and kills other enemies. The problem is that when there are many bullets on the screen it gets very slow because it has to move every picturebox.
View 11 Replies
Nov 12, 2010
I wonder how you can make a picturebox selectable at runtime and also change the size and location during runtime?
Well I know how i can change the location of a picture box during runtime but that is only with a picturebox that is already defined in the form before runtime.
So I write an event for that particular Picturebox.
But now i want to do the same thing with a picturebox that a user can add during runtime and then the user should be able to select and move the picturebox.
So now i can't add code to the picturebox event so I wonder how you should do this. ( Maybe with reflection?)
And what if the user added 10 picture boxes and selects a certain picturebox. How do you make it possible that the picturebox the user clicks on is selected?
Should you store each picture box location on the Panel and then when the user clicks on a certain pixel in the panel where a certain picture box is it get's selected?
View 3 Replies
Jan 20, 2009
i'm making a program and a need to put some pictureboxes in an array, when i try debugging it gives me an error, i can't figure out what its having trouble with :S
Public Class Form1
Dim itemArrayXO() As Color = {picXO1.BackColor, picXO2.BackColor}
Public Sub XO_Check(ByVal x As Integer)
[Code].....
(you may notice there are only 2 pictures in there, thats because im trying to get it to work before i go typing it all out)
View 2 Replies
Jan 7, 2010
I have 5 pictureboxes on my form and would like to but then in a collection or array to use them in a loop. I would like to use the FOR EACH loop... but how..
Th pictureboxes are placed in a Table. Here is my code so far.
Dim TableHeaders As String() = {"PERIOD", "GRADE", "SUBJECTS", "POSSIBLE ATTENDANCE", "ACTUAL ATTENDANCE", "% ATTENDANCE", "DISTICTIONS", "NUMBER ENROLLED", "STUDENTS WRITTEN", "STUD PASSED", "% RETAINING", "% PASSED", "TERM MARK", "NAT AVERAGE"}
[Code]...
It says that PictureBox is a type and can not be used as an expression, so how do i do it?
View 6 Replies
Apr 19, 2012
I'm making a game which involves putting an array of picture boxes in a panel. I can see the picture boxes, but some are cut off where the panel ends. I have also used:
My_PictureBox(Row, Column).SizeMode = PictureBoxSizeMode.StretchImage
View 6 Replies
Dec 2, 2011
I have text for ToolStripStatusLabel1.Text in a file which is read into an array.
There is an array of PictureBoxes, which are used for the MouseEnter event.
I am trying to display different text in the status when the mouse is over a certain image. In the code below, the Array.IndexOf() generates "Index was outside the bounds of the array.". The commented line will change the text when I change the Index but, it changes it for all images.
View 2 Replies
Oct 17, 2010
How to place units and their men on the form but I cant seem to get this array to work. It has multiple errors in it.
Dim pic(calctroops()) As New PictureBox
Dim z As Integer = 15
For i = 0 To Form3.orcunits
For x = 1 To Form3.orc(orcunits)
z = z + 15
pic(i).Location = New Point(Orc1.x + z, Orc1.y)
pic(i).BackColor = Color.Green
Me.Controls.Add(pic(i))
Next x
Next i
View 2 Replies
Sep 7, 2005
I have a VB2005 project that displays 16 pictureboxes in a 4x4 grid which display CD album covers. In VB6 I could set up a control array i.e. picCD(0) to picCD(15), which made drawing the CD covers a snap. How do I accomplish this in VB2005?
It seems extremely cumbersome to have code like: If Len(path(0)) < 1 Then
If Not IsNothing(PictureBox1.Image) Then
PictureBox1.Image.Dispose()
PictureBox1.Image = Nothing
End If
[Code] .....
View 5 Replies
Aug 10, 2009
My application has no static number of pictureboxes. I want to add picturebox to array control.
[Code]...
View 4 Replies
Oct 22, 2011
Private Sub ListOfCrops_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListOfCrops.SelectedIndexChanged
View 9 Replies
Feb 9, 2011
I have a program that has a large weather map which is 1920 x 1080 resolution. The start location is (0,0). I want people who use smaller resolutions to be able to see the whole map. I would like to create a button that allows me to shift the form down or right say 10 pixels each time the button is clicked. How would I do this?
View 1 Replies
Nov 2, 2010
I have 2 arrays, tile(13,6) and loc1tile(13,6). Is there a way to make the values in loc1tile(13,6) equal to the corresponding values of tile(13,6)?Do I have to do it like this?
loc1tile(0,0) = tile (0,0)
loc1tile(0,1) = tile (0,1)
loc1tile(0,2) = tile (0,2)
etc.....
View 7 Replies
Oct 31, 2010
This is my code for a class named Gun
Private GetCapacity As Integer
GetCounter As Integer
Private GetPosition As TV3D65.TV_3DVECTOR
'Make ".Property"'s called capacity, outofammo, etc..
Property Capacity As Integer
[Code]...
View 2 Replies
Oct 29, 2007
I was wondering if it was possible to make an array of a class. I made a class called creatures (for a game of course) and wanted to make an array of that class. So I tried "public creature() as new creatures", and it had a problem with using an array with new. Is there a way around this. All I am using the class for is variables. i.e.: in my class all i have is dim health, defense
View 12 Replies
Dec 1, 2009
is there a way to make an array but instead of listing the things yourself, you open a text file with a bunch of words and use those?
View 3 Replies
Dec 12, 2011
so this code works for making my array display in ascending order but i cant figure out how to make it work in descending order
[Code]...
View 3 Replies
Apr 18, 2009
I need to make an array of images using references to the resources folder. The following is my code which does not work:
Dim imgPictures(8) As Image
imgPictures(0) = Image.FromFile(My.Resources.cat_1.ToString)
How do I reference the images sitting in the resources folder for this task?
View 4 Replies
Jun 8, 2009
on my winform at runtime i will be resizing my array each time i add an element. so first i must resize to the size + 1, and then add a member to this index. how do i do this?
View 5 Replies
Sep 10, 2011
I've got a loop which should be executed three times.
[Code]....
View 4 Replies
Dec 13, 2010
Okay I'm tring to make a fairly simple class
[Code]...
View 2 Replies
Nov 8, 2011
i have a byte array in my code which contains hex values which is readed from a bin file. now what i want to do is cut this array into equal size of 4096 bytes and made new array,s at run time and assign first (4096) byte,s to first array and so own
View 6 Replies
Feb 23, 2010
Ok so i am currently working on a magic square game and basically my form creates an 2d array, dimensions make by user(ex:2 by 2), then the form creates the number of textboxes(Ex:4) and i need to get the values in runtime to check if it is a magic square
Dim MakeArr(dbltxt - 1, dbltxt - 1)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[code].....
View 7 Replies