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
Solved

loading controls

Posted on 2000-02-18
7
168 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
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.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 debug this code 7 64
recursion example 16 139
fso.FolderExists("\\server\HiddenFolder$") 4 78
Zip Folders Using Chilkat Routines 1 58
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 …
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.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

839 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