Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Filling TextBoxes

I want to fill several textboxes placed in a userform with the contents of
one textbox. My code is:

Private Sub getInfoFromTextBox1()
userForm1.startDatumTextBox1.text = userForm1.TextBox1.text
userForm1.startDatumTextBox2.text = userForm1.TextBox1.text
userForm1.startDatumTextBox3.text = userForm1.TextBox1.text
.......
End Sub

Now I understand that you can do this in a more efficient manner by looping
it. I got some help but I dont know how to use it (my help function is not
working). The code that I got is:

For each Control in (whatever object you are working with) if Control.name
like "Control*" then
In here I then use Strings.left or Strings.right to sequence my way
through
each of the ending digits. Or I use some other variation on this
theme.
End if

I dont really know how to use it in my case..(i am really bad at VB...).
Please help me out! Would be most greatful!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Filling TextBoxes

Try:

Private Sub getInfoFromTextBox1()
Dim i As Integer
For i = 1 To 3
Me.Controls("startDatumTextBox" & i).Text = TextBox1.Text
Next
End Sub

The controls also have an index property in addition to a name property as
shown above. The index value depends on the order they were added to the UF.
However, the first control added will have an index value of zero (0), not 1.

If the textboxes were added in sequence and TextBox1 was the 4th control
added (index = 3) and the others were added in sequence then you could also
use this:

Private Sub getInfoFromTextBox1()
Dim i As Integer
For i = 4 To 6
Me.Controls(i).Text = Me.Controls(3).Text
Next
End Sub

Regards,
Greg


"Freddie Mac" wrote:

I want to fill several textboxes placed in a userform with the contents of
one textbox. My code is:

Private Sub getInfoFromTextBox1()
userForm1.startDatumTextBox1.text = userForm1.TextBox1.text
userForm1.startDatumTextBox2.text = userForm1.TextBox1.text
userForm1.startDatumTextBox3.text = userForm1.TextBox1.text
......
End Sub

Now I understand that you can do this in a more efficient manner by looping
it. I got some help but I dont know how to use it (my help function is not
working). The code that I got is:

For each Control in (whatever object you are working with) if Control.name
like "Control*" then
In here I then use Strings.left or Strings.right to sequence my way
through
each of the ending digits. Or I use some other variation on this
theme.
End if

I dont really know how to use it in my case..(i am really bad at VB...).
Please help me out! Would be most greatful!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textboxes JFL Excel Programming 0 November 23rd 05 02:03 PM
filling userform textboxes Pierre via OfficeKB.com[_2_] Excel Programming 3 October 14th 05 08:16 PM
filling information from one cell and filling another. Dianne Excel Worksheet Functions 1 August 15th 05 08:14 PM
Filling Cells from Textboxes trini Excel Programming 3 February 19th 05 09:37 PM
searching for a combobox.value and filling in textboxes from results GregJG[_18_] Excel Programming 3 July 8th 04 12:41 PM


All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"