Solved

VB 4.0 - Creating Objects on the Fly

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 173
Excel object stays open 19 70
Add a task in Outlook from access 11 35
SLMGR Switches Are Not Working On KMS Host 3 63
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

932 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

14 Experts available now in Live!

Get 1:1 Help Now