Hello,
I think the subject said it all. So, is it possible??
Thank you.
Printable View
Hello,
I think the subject said it all. So, is it possible??
Thank you.
make sure that RichTextBox is in the components list.
uncheck "Remove information about unused activeX controls" in the 'Make' tab of the project properties.
then it's just a case of doing:VB Code:
Private WithEvents rtb As RichTextLib.RichTextBox Private Sub Form_Load() Set rtb = Me.Controls.Add("RICHTEXT.RichTextCtrl.1", "RichTextBox1") rtb.Visible = True End Sub
Thank you so much!!
BTW, what is the significance of .1 in the Add function??
no probs :thumb:Quote:
Originally Posted by Harsh Gupta
i don't think there's any significance, it's just the ProgId.
do:and you'll see what I mean.VB Code:
Set rtb = Me.Controls.Add("RichTextLib.RichTextBox", "rtb")
Ok, did a bit of RnD on ProgID. Searched the Reg Editor and noticed that almost all controls we use, the Reg Edit. has 2 ProgIDs, one with .1 and another without .1 but both having same CLSID, and further digging into the CLSID revealed that the ID with .1 has a Key [VersionIndependentProgID], its value being the ProgID without .1.
From ProgID on VBAccelerator
Talking about RichTextLib.RichTextBox, if I make my own version of RTB and name it RichTextLib.RichTextBox.2, then will it:Quote:
When you request an instance of the cFlatControl class, COM looks up the ProgID "vbalFCtl.cFlatControl" which gives it the GUID of the object. COM can then locate the GUID and therefore the path to the object. This is where the problem arises with two objects with the same ProgID. If you create a new version of the Flat Control DLL, say it either has with different methods or it is compiled in VB6 instead of VB5, you will automatically generate a new GUID. However, if you don't change either the project name or the class name, you will overwrite the existing ProgID with your own version. Anyone else's code which expects to get an instance of the object suddenly gets routed to the new version, and their code may then fail depending on what you've done to the existing class.
1) Generate a new progID? or
2) Overwrite the old progID (i.e. overwrite the RichTextLib.RichTextBox.1)? or
3) Rest in harmony with the default two?
Thank you.
This FAQ will also help.
Sorry, but the link said nothing about the ProgID concept!!Quote:
Originally Posted by MartinLiss
I have the answer to my original question. There is something related to it that I haven't understood.
Most times the easiest way to dyanamically create and get rid of controls at run time is to create a control array. You can do this by simple copying as pasting a copy of the control on the form. then you can delete the extra one. This sets up an array of controls that can be created with the load statement. Then you assign properties to the new control.
load some_control(index number)
With some_control(index number)
.Top = 300
.Left = 500
.Text = "Some Text"
End With
Hope this helped
hmmf....I shall mark this thread resolved and ask the second question in GD section.