Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

loading controls

Posted on 2000-02-18
7
Medium Priority
?
172 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
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.
Suggested Courses

609 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