473,947 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
+ 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.ToStr ing.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 1108
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(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim txtboxarea As TextBox() = New TextBox() {TextBox1, TextBox2}
For Each txt As TextBox In txtboxarea
AddHandler txt.LostFocus, AddressOf TextBox_LostFoc us
Next
End Sub
Private Sub TextBox_LostFoc us(ByVal sender As Object, _
ByVal e As System.EventArg s)
DirectCast(send er, 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********@hot mail.com> wrote in message
news:25******** *************** ***@posting.goo gle.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.ToStr ing.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********@hotm ail.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********@hotm ail.com (Edward) wrote in message news:<25******* *************** ****@posting.go ogle.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.ToStr ing.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
8468
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 will be. I can create the text box and name it (Answer01, 02, 03 ect.), please see code below. The question I have, is how do I loop through the number of text boxes when I submit the form to another asp page? For example, if I have 20 text boxes...
4
1538
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 can do this in a loop? The only way I can see to do this is to go if isempty(TB1) then...endif if isempty(TB2)then...endif which will involve 25 if statements. I was kind of hoping to do this in a for loop if possible. Thanks P.S. Using...
5
4016
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 attempt was to put the controls in a Panel, and then loop through the controls collection of the panel. What happened is it read the controls from the bottom of my form to the top! So I tried a more manual process. I named each textbox like this:
1
1325
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 code I have done for the first 2 check boxes, name and world, they do what I want them to do, but for the rest of the check boxes, the codes would be a bit minotonous. Is there a better way of doing this, maybe checkedboxlist?
2
4735
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 question. I have a web survey that I am working on and have successfully dynamically taken the info from a database, displayed it on the screen and then taken the users answers and inserted them into a
1
4584
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
1793
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 also needed/had to, because OF LACK OF EXPERIENCE, figure out wheter my finding was true first 'before out putting, thus Text1.Text = Text6.SelLength = Len(strGetWords) was born 'when true, Text2.Text = strGetWords 'Here is the problem, I searched...
1
1860
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 is the looping is not displaying the all contents of the arrays. Do you have any idea what the problem is and how to fix the problem?
12
3377
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 entered. Ideally I'd want to run through the records until I find one that matches with the entered UserID and then compare passwords. I've googled and I can't really find any examples of how to do this.
0
9983
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10694
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9890
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8256
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6118
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.