PC Review


Reply
Thread Tools Rate Thread

How to create new textboxes during runtime?When user clicks on a button textbox shouls appear.

 
 
divya
Guest
Posts: n/a
 
      23rd Nov 2006
Can any body help me with the code used to dynamically create textboxes
during run time .
I am having 2 textboxes Name and Phone number , Aligned side by side.
Now if user wants to add another person's contact details he will click
on button with caption "+" .I want that when he clicks on this button
two textboxes Name and Phone number shouls appear below the previous
Name and Phone Number text box.
III'ly if he wants to add one more person's name and contact he will
again click on the "+" button and then again 2 new text boxes should
appear below the 2nd person's text boxes.

Kindly help me with how to give the position of the textboxes to be
created during run time,how to make them and later how to access the
values of these dynamically created textboxes .

 
Reply With Quote
 
 
 
 
wisccal@googlemail.com
Guest
Posts: n/a
 
      23rd Nov 2006
I would do it as follows:

'============================
'frm: The User Form to add the TextBox to
'name: the name assigned to the TextBox
'x: Position from left edge in pixels
'y: Position from top edge in pixels

Public Sub addTextBox(ByVal frm As UserForm, ByVal name As String,
ByVal x As Integer, ByVal y As Integer) As MSForms.TextBox

Dim txt As MSForms.TextBox

Set txt = frm.Controls.Add("Forms.TextBox.1", name, True)

With txt
.Top = y
.Left = x
End With

End Sub
'============================

If you call this sub like so:

addTextBox(UserForm1, "MyTextBox", 10, 20)

....you will be able to extract values as follows:

UserForm1.Controls("MyTextBox").Text

Let me know if that meets your needs.

Regards,
Steve

divya schrieb:

> Can any body help me with the code used to dynamically create textboxes
> during run time .
> I am having 2 textboxes Name and Phone number , Aligned side by side.
> Now if user wants to add another person's contact details he will click
> on button with caption "+" .I want that when he clicks on this button
> two textboxes Name and Phone number shouls appear below the previous
> Name and Phone Number text box.
> III'ly if he wants to add one more person's name and contact he will
> again click on the "+" button and then again 2 new text boxes should
> appear below the 2nd person's text boxes.
>
> Kindly help me with how to give the position of the textboxes to be
> created during run time,how to make them and later how to access the
> values of these dynamically created textboxes .


 
Reply With Quote
 
Craig M
Guest
Posts: n/a
 
      24th Nov 2006
Do you need to create the textbox during runtime? Could you create them, the
use the visible property when needed?

Craig

"divya" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Can any body help me with the code used to dynamically create textboxes
> during run time .
> I am having 2 textboxes Name and Phone number , Aligned side by side.
> Now if user wants to add another person's contact details he will click
> on button with caption "+" .I want that when he clicks on this button
> two textboxes Name and Phone number shouls appear below the previous
> Name and Phone Number text box.
> III'ly if he wants to add one more person's name and contact he will
> again click on the "+" button and then again 2 new text boxes should
> appear below the 2nd person's text boxes.
>
> Kindly help me with how to give the position of the textboxes to be
> created during run time,how to make them and later how to access the
> values of these dynamically created textboxes .
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting when user clicks Red X button ssg31415926 Microsoft Dot NET Framework Forms 3 23rd Aug 2007 11:53 AM
How to change the filename when the user clicks OK button sowen Microsoft C# .NET 1 24th Nov 2006 08:36 PM
Button clicks and textbox Exit events Linc Microsoft Excel Programming 3 26th Dec 2005 11:23 PM
2 Message Boxes Displayed when User Clicks Button jburkle Microsoft VB .NET 0 17th Oct 2005 08:17 PM
Need Javascript - if user clicks in textbox, label not visible =?Utf-8?B?U2FuZHk=?= Microsoft ASP .NET 7 10th Jul 2005 04:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:11 AM.