Solved

loading controls

Posted on 2000-02-18
7
165 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
  • 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 20 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

744 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

13 Experts available now in Live!

Get 1:1 Help Now