Solved

VB 4.0 - Creating Objects on the Fly

Posted on 1997-08-05
3
142 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now