Message 1 of 4
how to use vbe to add control to form?
Not applicable
03-05-2002
09:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to add a control to a form programatically which I've got a hint
from the help that that might be possible. I've never heard of it before
and the help seems really vague to me about the vbe methods.
I've tried variations of the following:
Sub testput()
Dim sFormName As String
Dim sTbName As String
Dim dVertPos As Double
Dim dHorizPos As Double
Dim dWidth As Double
Dim dHeight As Double
sFormName = "UserForm2"
sTbName = "TextBoxTest"
dVertPos = 45
dHorizPos = 45
dWidth = 45
dHeight = 15
PutTextBoxOnForm sFormName, sTbName, dVertPos, dHorizPos, dWidth, dHeight
End Sub
Sub PutTextBoxOnForm(sFormName As String, sTbName As String, dVertPos As
Double, dHorizPos As Double, dWidth As Double, dHeight As Double)
Dim ctlTbox1 As TextBox
'if I have a form named "UserForm2" that I want to put the control on
Dim frmTest As UserForm2
Set frmTest = New UserForm2
'this doesn't work
frmtest.Controls.Add textbox
'nor this
Set ctlTbox1 =
Application.VBE.SelectVBComponent.Designer.Controls.Add(vbext_ct_TextBox)
Set ctlTbox1 = Nothing
End Sub
I'm really just flailing away in the dark here, couldn't figure out from the
help files what I need to do.
Has anyone got this down ????
--
Mark@atreng.com
A.T. Renczarski and Co., inc.
p 816.587.0101
f 816.587.5691
I'm trying to add a control to a form programatically which I've got a hint
from the help that that might be possible. I've never heard of it before
and the help seems really vague to me about the vbe methods.
I've tried variations of the following:
Sub testput()
Dim sFormName As String
Dim sTbName As String
Dim dVertPos As Double
Dim dHorizPos As Double
Dim dWidth As Double
Dim dHeight As Double
sFormName = "UserForm2"
sTbName = "TextBoxTest"
dVertPos = 45
dHorizPos = 45
dWidth = 45
dHeight = 15
PutTextBoxOnForm sFormName, sTbName, dVertPos, dHorizPos, dWidth, dHeight
End Sub
Sub PutTextBoxOnForm(sFormName As String, sTbName As String, dVertPos As
Double, dHorizPos As Double, dWidth As Double, dHeight As Double)
Dim ctlTbox1 As TextBox
'if I have a form named "UserForm2" that I want to put the control on
Dim frmTest As UserForm2
Set frmTest = New UserForm2
'this doesn't work
frmtest.Controls.Add textbox
'nor this
Set ctlTbox1 =
Application.VBE.SelectVBComponent.Designer.Controls.Add(vbext_ct_TextBox)
Set ctlTbox1 = Nothing
End Sub
I'm really just flailing away in the dark here, couldn't figure out from the
help files what I need to do.
Has anyone got this down ????
--
Mark@atreng.com
A.T. Renczarski and Co., inc.
p 816.587.0101
f 816.587.5691