?
Solved

loading controls

Posted on 2000-02-18
7
Medium Priority
?
171 Views
Last Modified: 2013-11-13
I need to load a richtextbox during run time when a certain thing happens.

I use to do this with winsock on an array but I can't seem to do it the same way.   Any suggestions ?

So far i've got it loading a new one up setting it's position and making it visible but it's not working.
0
Comment
Question by:Dark_Angel
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2537396
What have you used to do this ? Have you tried using controls collection to do that ? Here is a sample code.
Dim withevents ctlCommand as VB.COmmandButton

Set ctlCommand = Controls.Add("VB.CommandButton", _
                    "ctlCommand1", Form1)
ctlcommand.move 0,0
ctlcommand.caption = "YAHOO"

Thats how the control is born in runtime. I suppose if you loading an ActiveX control it must be stil referenced i would think. I think the control then must be redestributed when you making a setup.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2537915
I guess you are using a control array ?

I would normally have an instance of the control on a form, set its index to zero and make it invisible.

Then at run time do:

    Load myControl(NextControlIndex)
    With myControl(NextcontrolIndex)
        .Left = 100
        .Top = 100
        .Visible = True
    End With
    NextControlIndex = NextControlIndex+1

If thats what you're doing, in what way is it not working ?
0
 
LVL 3

Accepted Solution

by:
paulstamp earned 60 total points
ID: 2537918
Just tried the below code and it works... place a RTB on a form and a button. Then put the following code into the button and run. Everytime you press the button a new rich text box appears below and to the right of the last one :

Private Sub Command1_Click()

    Static nIndex As Integer
   
    nIndex = nIndex + 1
    Load RichTextBox1(nIndex)
    With RichTextBox1(nIndex)
        .Left = nIndex * .Width
        .Top = nIndex * .Height
        .Visible = True
    End With
   
End Sub
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 6

Expert Comment

by:Marine
ID: 2538060
The problem with your code is guys that he doesn't want to create a control array in runtime he wants just a control in runtime wihtout having any control on the form at all where you just use load to create one. So the only way is to use VB Controls.ADD method to do so. Or there should be an API function similar to this.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2538128
VB6 supports .Add, Vb5 does not. If he's using VB5 then he must use an invisible "seed" control for the control array.

M
0
 

Author Comment

by:Dark_Angel
ID: 2539358
Thanks for the high interest..

I at first was going to load a richtextbox but I saw the array code and I think that will be easier since I'm not sure if i'll be needing more then one.

Thanks for all the info!
0
 

Author Comment

by:Dark_Angel
ID: 2539361
Thanks for the code
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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…
Suggested Courses

771 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