Welcome to Dream.In.Code
Become a VB Expert!

Join 149,937 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,428 people online right now. Registration is fast and FREE... Join Now!




how can I make an object with parameters?

 
Reply to this topicStart new topic

how can I make an object with parameters?, object with parameters

Rhagoletis
19 Jan, 2008 - 06:20 PM
Post #1

New D.I.C Head
*

Joined: 19 Jan, 2008
Posts: 1

Board1 is an instance of a chessboard class. What should I write in the class if I want to manipulate board's squares writing board1(x,y).occupied ? I can't find out how can I make a class which it's objects will have parameters (x,y). I use visual Basic 6
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: How Can I Make An Object With Parameters?
19 Jan, 2008 - 09:47 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
While we don't just hand code out here at </dream.in.code> we don't have a problem nudging you in the right direction, but you have to write the code first, and if you run into problems with the code you're writing post it here, using code tags like so code.gif
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: How Can I Make An Object With Parameters?
19 Jan, 2008 - 10:00 PM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
How are you implementing Board1? In a cls file as a class?

You have to first understand that VB 6 doesn't support parameterized constructors. Why? Because VB 6 is not fully object oriented. VB.NET has implemented constructors and has full support for classes. So the best you can do is create a Board cls class file, provide it a method by which you can pass two variables, have it return a square class which has a property called "occupied". So one CLS file for board, one for something like a class called "square".

Your square class module will then contain a simple property defined like...

CODE

' Set and Let property definition for Square class.
Public Property Get Occupied() As Boolean
  Occupied = occupied_status_member_var
End Property

Public Property Let Occupied(NewValue As Boolean)
  occupied_status_member_var = NewValue
End Property


So what you do is with the board class create a two dimensional array of square classes that each have a property called "occupied".

Hope it makes sense. smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 04:25PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month