VB.NET Programming Tutorial – Creating Classes and Managing Object Arrays (Visual Basic .NET)

This Visual Basic programming tutorial is designed to complement my Visual Basic Game Programming series, but is not limited to game design. It is designed to teach you how to create a custom VB Object Class, store your class to an object array, then create and delete multiple instances of that class on the fly.

In this VB programming video, we will be performing the following tasks:
1.) Building a simple game/application loop
2.) Build a (GDI+) graphical interface for painting objects to the main form
3.) Build a custom class with graphical properties and embedded timer objects and self-contained events
4.) Teach the objects to interface with the form environment while remaining autonomous
5.) Create a class/object array to store a desired number of objects from our class
6.) Use random numbers to dynamically generate new and diverse instances of our custom class
7.) Destroy specific objects by deleting them from our array when certain conditions are met.

PROJECT SOURCE CODE: http://www.aardaerimus.com/downloads/classtutorial/


Aardaerimus D'Aritonyss says:

He’s right. :-) That would indeed be a good use, although one could still preclude a movement cycle by performing a similar look-up in the movement routine.

I’m very happy that the videos have been helpful for you! It’s gratifying to know that they’ve been instrumental in helping people grow. 😀

Richard Arden says:

@Aardaerimus humm sorry i think i just mest my post up new to this ::)

Aardaerimus D'Aritonyss says:

@klutchego I was actually thinking about doing a tutorial on using MySQL with VB for storing user accounts and whatnot. 😀 Maybe I’ll try tackling this, but I HAVE to figure out this XNA before it kills me. hahah

NoLongerBe says:

GREAT INTRO MUSIC!!! wondering if you can tell me what song you were playing?

Stuart Chandler says:

The presented information was just what I need for my application. While my application is not a game your presentation was ideal in understanding the use of classes. Thank you for providing me with a good start much appreciated.

Asfaw Yimer says:


Comunidad GLLA says:

very useful tutorial!

Feral Cypher says:

I finished the tutorial and I learned a lot. Thanks for taking the time to put this together. I do a question though. I received a “Object reference not set to an instance of an object” error after running the code at line:

Sub DrawCritter()
Form1.G.DrawImage(spriteBmp, critterX, critterY, spriteRect, GraphicsUnit.Pixel)

Any idea what cause it?

kevnar says:

Let me guess. You left the Y coordinate of your butterfly sprite at 0 just to see if we were paying attention. :-p

dong fan says:

this step by step instruction video really helps, waiting for more to come

Brooks Norton says:

Thank you so much.  I’ve been struggling…  Huge help.

rest selasi says:

thanks for the tutorial. really helpful

NoLongerBe says:

lol. nice ! if possible, can u send me the full version of that piece ? It was so nice ! I love it and somehow the melody is stuck in my head

Aardaerimus D'Aritonyss says:

Hello, Pharoah Cypher. Which part of the video are you stuck at?

Taibi Karim says:

Great tut, thanks a lot
much faster than reading books.
wishes from morocco

Peter Boothby says:

Thanks Aardaerimus, this is a great series of tutes! I’m moving my MS Office VBA experience into creating VB programs & this is a great way to learn. Kepp em coming !!  :  )

Richard Arden says:

True although i watched all of it and lol did not realize it was that long ::) time always goes quick when u enjoying something.

TheOrneryNerd says:

Hey, Aardaerimus!!!
I’m still waiting for the promised mouse controll movement video + by steps by timer (few steps per turn) ….!!! j/k :)

Thanks for great video once again!

akmal niazi khan says:

Programming is very interesting and creative thing if you do it with love. Your blog code helps a lot to beginners to learn programming from basic to advance level. I really love this blog because I learn a lot from here and this process is still continuing.
Love from Pro Programmer

Pambhar Vishal says:

It is very help full to me….thanks a lot…..
just one request …from where I can find your previous videos.
I mean from beginners..

rest selasi says:

please kindly get the camera close a little bit so we can see the codes. thanks!!

Silver ImpAct says:

wow!very useful THX in millions

Paul Chabot says:

Great Video! I know this wasn’t a primary focus of your video, but I’ve been looking up class creating stuff to see how to properly use Private, ReadOnly and Public Variables, Properties, and Methods within a class. I understand all your declarations except the “Public Sub SpriteSource()”. It seems since it’s only usefully referred to by the “Set” part of the “CritterType” property it might be more securely declared as “Private.” Do I understand that correctly or am I missing some detail?

Aardaerimus D'Aritonyss says:

@TheOrneryNerd Hahah RIght you are! 😀 I need to get on that.

I’m in a real pickle right now, because I want to carry on using XNA in place of GDI+, but custom classes are not playing well with the main form. I’m hoping that rm2kdev can shed some light on the situation so I can move forward with the tutorials.

Pete Ridley says:

Really good and informative tutorial at a pace I could keep up. Thanks!

a77mighty666 says:

I started to learn game programming a few years ago now, but gave up a couple year ago as HDD blew up and i lost all my work. This video is just what i needed to refresh my memory of all the fundamentals. Really great tutorial, i look forward to watching more of your videos tomorrow! 😀

Feral Cypher says:

I’m new to VB and the Application class isn’t available on my system. How do I fix this? I really want to follow along.

Richard Arden says:

@Aardaerimus True although i watched all of it and lol did not realize it was that long ::) time always goes quick when u enjoying something.

Richard Arden says:


Richard Arden says:

need that coffee now ::)

Gamal Abdall says:

Great, I am glad to find your videos again, I followed all your work from VB-ToolBox

Thank you and hope to hear or see your work always , I am going to subscribe here as its different from vbtoolbox videos.

3,450,931 views says:

the programming name is good but codes not clear

Matthew Jemmett says:

Another Great tut, Thanks =D

Aardaerimus D'Aritonyss says:

Right you are, Paul! I’m not sure what I was thinking there. 😛

This is a really old video and my style of coding and proficiency has changed dramatically since I made some of these older videos.

Any more, I never even use the class “property” builders as I’ve found no tangible benefit over standard subs and variables.

It’s much easier to simply define a publicly accessible variable as a property with one line of code, than a Property base that immediately begins with eight lines. 😀

Paul Chabot says:

My coworker points out that if you’re validating a variable every time its changes, the setter is a great place to do that rather than in each place you change the variable. For instance, if you wanted to make sure a character didn’t move off the map, you could have the setter check if new coordinate will be within the map and if it’s not, set the coordinate to the edge of the map.

On another note, thanks for the videos! You’re channel’s been a big part of my programming development!

Aardaerimus D'Aritonyss says:

Thanks, NoLongerBe! 😀

I compose all of my own music, so it’s an original piece.

TheGachinima says:

Very Nice 😀

Aardaerimus D'Aritonyss says:

Thank you, thank you! 😀

I played this on my keyboard and recorded with with Audacity (free sound recorder).

buddyroach says:

im not sure vb is the software to use for game making but you can make some nice programs with it. i have

Feral Cypher says:

I created the program as a Console app by accident instead of a Form app. It’s working now. The Application.DoEvents() method isn’t available in the Console program.

Write a comment


Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours