Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find If Control Is Loaded 1

Status
Not open for further replies.

MrVB50au

Programmer
Mar 16, 2003
326
0
0
AU
Hi,

How can I find out if a control array is loaded or not?

Example:

I'm drawing textboxes on a form, do all the text formatting as Bold, Italics, Size, etc. Once I had drawn a few I double click the form and the textboxes are then replaced by an array of label controls copying all the formatting of the text to each matching label control in the matching array.

Now, when I go to create somemore textboxes on the form and double click the form I find that the label controls don't appear and the textboxes are still visible.

Here is the procedure I have called from the Form_DoubleClick() event.

Code:
Option Explicit

Dim LoadedInx As Integer
Dim Inx As Integer

Sub FinishText()
    '
    On Error GoTo ArrayErr
    LoadedInx = Text1.Count
    For Inx = 1 To LoadedInx
        Load Label1(Inx)
        With Label1(Inx)
            .Caption = Text1(Inx).Text
            .Font.Name = Text1(Inx).Font.Name
            .Font.Bold = Text1(Inx).Font.Bold
            .Font.Size = Text1(Inx).Font.Size
            .Top = Text1(Inx).Top
            .Left = Text1(Inx).Left
            .Width = Text1(Inx).Width
            .Height = Text1(Inx).Height
            .Visible = True
        End With
        Text1(Inx).Visible = False
    Next Inx
    '
End Sub

Can you please help me find where I'm going wrong?

Thank You,

Andrew.
 
I have the same problem. Any solutions to this? I get the 360: Object already loaded error. I have tried various Is Nothing, IsNull etc with no luck...

[elephant2]
graabein
 
If you are trying to prevent editing of the text boxes why not just disable them and change the .forecolor property? That way you don't have to worry about the labels at all.

zemp
 
I'm not quite sure what you mean when you say that you
when I go to create somemore textboxes
I think you are creating say 20 textboxes, and then when you foubleclick the form, these disappear and 20 lables appear. Then you want to add 20 more textboxes, so that a total of 40 + 1 original on the form. Is this right? Then when you double click again you want the second batch of 20 labels to appear.

Can you confirm this is what you are trying to do?

BB
 
I don't know what mrvb50au is doing but I have a user control array that varies in size from time to time. The first time I load new controls with Load operationSchema(i) and the next time I get the 360 error. What test do I have to run on the array to see if the control is loaded or not?
 
You should be able to use the following to see how many controls are in the control array. Then adjust your variable i accordingly.
Code:
operationSchema().Ubound
The .Count property might also work.

zemp
 
MrVB50au,

You are trying to load your second lot of labels with index 1, 2, 3 .. etc over labels which already have those indexes ie the ones created the last time FinishText() ran.

Your loop should start something like;

For i = label1.count-1 to LoadedInx

regards Hugh,
 
OK, I have worked out my problem and I do apologize for the late response. However, this had raised an important question: "Why" am I creating labels and not "Disabling" textboxes? The answer to that is quite simple: Textboxes don't have the transparency property as label controls do.

Lets say for argument sake that you have created a greeting card program with lots of graphics on a background, you'd like to simply draw a textbox, type and format the text, then simply click anywhere outside the textbox area to automatically have text with a transparent background.

ANOTHER QUESTION:
Is it possible to have a text box grow while you type if it's outside the boundaries that you had created it when you first drew the actual textbox and when you press the [Enter] key the textbox will grow in height according to the font size and all other formatting?

Please don't just say yes. Give me an example to work on if possible please!

Thanks everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top