473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Looping through a bunch of text boxes

VB.NET

I have a bunch of textboxes on my form

txtPart1
txtPart2
....
txtPart16

When the user presses "Ok", I need to concatenate the values into a
single string and paste it into an email.

I wondered about this (AIR CODE):

Dim strParts As String
Dim iintIndex As Integer

For iintIndex = 1 To 16 Step 1
strParts &= Me.txtPart & iintIndex.ToString.Text
Next

Is something like this possible? I realise the above is syntactically
incorrect, by the way!

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk
Nov 20 '05 #1
4 1091
Cor
Hi Edward,

There are a lot of posibilities,

This is one that I find at this moment the nicest.
(This sample delete the spaces in front and end in textbox1 and textbox2).

I hope this helps?

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim txtboxarea As TextBox() = New TextBox() {TextBox1, TextBox2}
For Each txt As TextBox In txtboxarea
AddHandler txt.LostFocus, AddressOf TextBox_LostFocus
Next
End Sub
Private Sub TextBox_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
DirectCast(sender, TextBox).Text = _
Trim(DirectCast(sender, TextBox).Text)
End Sub
///
Cor
Nov 20 '05 #2
Dim fullString as String
For each ctrl as Control in me.Controls
If TypeOf(ctrl) is TextBox Then
fullString += ctrl.Text
End If
End For

HTH

Rigga.

"Edward" <te********@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
VB.NET

I have a bunch of textboxes on my form

txtPart1
txtPart2
...
txtPart16

When the user presses "Ok", I need to concatenate the values into a
single string and paste it into an email.

I wondered about this (AIR CODE):

Dim strParts As String
Dim iintIndex As Integer

For iintIndex = 1 To 16 Step 1
strParts &= Me.txtPart & iintIndex.ToString.Text
Next

Is something like this possible? I realise the above is syntactically
incorrect, by the way!

TIA

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk

Nov 20 '05 #3
* te********@hotmail.com (Edward) scripsit:
I have a bunch of textboxes on my form

txtPart1
txtPart2
...
txtPart16

When the user presses "Ok", I need to concatenate the values into a
single string and paste it into an email.


\\\
Dim atxt() As TextBox = {TextBox1, ..., TextBox16}
Dim txt As TextBox
For Each txt In atxt
...
Next txt
///
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #4
te********@hotmail.com (Edward) wrote in message news:<25**************************@posting.google. com>...
VB.NET

I have a bunch of textboxes on my form

txtPart1
txtPart2
...
txtPart16

When the user presses "Ok", I need to concatenate the values into a
single string and paste it into an email.

I wondered about this (AIR CODE):

Dim strParts As String
Dim iintIndex As Integer

For iintIndex = 1 To 16 Step 1
strParts &= Me.txtPart & iintIndex.ToString.Text
Next

Is something like this possible? I realise the above is syntactically
incorrect, by the way!

TIA

Edward


All excellent suggestions - many thanks!

Edward
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steven K | last post by:
Hello, I have a form that loops through a set of questions pulled from a database and creates text boxes for the answers to the quesetions. I don't know before hand how many questions there...
4
by: Enterprise | last post by:
Hi, I have 25 text boxes in a form. Lets say TB1 through TB25 are the Names of the boxes. They have no controll sources. I want to be able to check whether the text box is empty. Is there anyway I...
5
by: johnb41 | last post by:
I need to loop through a bunch of textbox controls on my form. The order of the loop is very important. For example, the top one must be read first, then the one below it, etc. My first...
1
by: Demonicpagan | last post by:
I have this form where I am trying to place items from checked boxes into a text box. An image of what this form looks like is at http://www.stelth2000inc.com/images/screen.png Here is some...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
1
by: Mel | last post by:
I need to loop through all form elements such as text, radios, check boxes and the like and to save their state in a file. does anyone have JS code to do this ? It can help a bunch thanks
18
Dököll
by: Dököll | last post by:
Here it goes again, thanks again for responding: 'PROPOSED SOLUTION 2 'I wanted to not creatre a file and just read straight out of Text6.Text and 'output my findings in legal text boxes 'I...
1
by: assgar | last post by:
Hello I have changed the process code abit so it receives the data from the form and ensures the data in array format. This has eliminated my previous error. The problem I am experiencing...
12
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I'm creating a hashtable of a list of users in AD. The keys are UserID and Password. I want to loop through the table to compare the userID and password with values that a user has...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.