Creating VB objects programmatically

hi,

i am trying to create a program that opens a text file and designs a form according to this text file.

the problem i am having is that i cant create a vb object (checkbox, textbox etc) programmatically..

I have tryed the following:

Dim asdf As TextBox

with asdf.
      .alignment = "XXX"
     ' and so on
end with
but that doesnt work.. i am not quite sure how to do this..

Any help will be appreciated
Thanks
apoorvamehtaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try like:

Dim asdf As TextBox

Private Sub Form_Load()
    Set asdf = Me.Controls.Add("VB.TextBox", "asdf")
   
    With asdf
        .Alignment = 1
        .Visible = True
        .Left = 0
        .Top = 20
        .Text = "hello world"
    End With
   
    MsgBox asdf.Name
End Sub

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
apoorvamehtaAuthor Commented:
Thanks!!

did u know why the text is on the right sided of the textbox..

when i make a check box.. i get the chekbox on the left of the text..

0
apoorvamehtaAuthor Commented:
i meant.. i get the checkbox on the right of the text unlike the normal checkbox
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

apoorvamehtaAuthor Commented:
i am sorry.. really stupid question..
(the alignment should be 1..)

thanks again
have a good day
Apoorva
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>when i make a check box.. i get the chekbox on the left of the text..
That's what a typical checkbox is it. If you want to make the text appears to the left of checkbox, you can:

1. empty the Caption property of that checkbox
2. and then add a label on the left of that checkbox, and type the text whatever you wanted.

Anyway, thks for the pts, and glad could make help here 8-) cheers
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
It's ok, apoorvamehta. 8-) Have a nice day too.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
Damn.. my mistake...  if you want to have a checkbox with text align on left, you can try like:

Dim WithEvents asdf As CheckBox

Private Sub Form_Load()
    Set asdf = Me.Controls.Add("VB.CheckBox", "text2")
   
    With asdf
        .Alignment = 1
        .Visible = True
        .Left = 0
        .Top = 20
        .Caption = "hello world"
    End With
   
    MsgBox asdf.Name
End Sub

Private Sub asdf_Click()
    MsgBox "you click me!"
End Sub

Sorry if i misunderstand your above question ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.