Solved

VB 4.0 - Creating Objects on the Fly

Posted on 1997-08-05
3
162 Views
Last Modified: 2012-05-04
I have a situation where I want to create a releated object for each database record I read in. Basically I want to create probably a picture box or image for each record read in. Each record may have an associated BMP.

In reading the records from the table I want to create an object for each an load this onto the form. The will have to be moveable as I want to be able to drag & Drop these into a certain position.

I will give you an example.  I have a sports Database where there are teams entered.  For each round in the competition I want the user to be able to associate the teams playing each other. I want to create an object for each team on the right part of the form then associated Home & Away playing team in the left part of the form.

Thanks in Advance
0
Comment
Question by:trevorm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:dansari
ID: 1429762
trevorm:

Why don't you store the X and Y coordinates (Left and Top properties) of each picture box control in the database?  In the Form_Unload event (or using a Save button, or something), you can save the values.

If the number of players and teams is fixed, then you can create the picture box controls at design time; otherwise, you can use control arrays.

Hope this helps.
0
 

Accepted Solution

by:
hfanan earned 200 total points
ID: 1429763
I faced this problem before with Edit Box but the solution is the same for picture boxes.
Define a control array of picture boxes. Let its name be "P"
To create a new control dynamically use the Load command.
For example Load P(i) where i is the index of the array.
To remove the control from memry, use the UnLoad command
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1429764
Here's another trick.  Make your data structures do the work.  Put the file name of the bmp, or the icon name if using an image list, in your records.  That way when you read the record, it defines its own image.  Then if you want to change images, just refile another .bmp under the same file name on your drive.


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question