473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

loop with field names

Hi everybody,

I want something like I used in MS Access:

for i = 1 to 20
me("FieldName" & i).Text = "Text bla bla bla"
next i

I want something like that because I have a series of fields like
FieldName1; FieldName2, FieldName3, ... which I want to fill in
programmaticaly.

thanks in advance

Filip
Nov 22 '05 #1
12 1325
Filip,

What is the problem with that

I want something like I used in MS Access:

for i = 1 to 20
me("FieldName" & i).Text = "Text bla bla bla"
next i

\\\by instance roughly typed
for ctr in me.controls
dim number as integer = Cint(ctr.text.substring(9,0))
if number. > 0 AndAlso number < 21 then
ctr.text = "Text bla bla bla"
end if
Next
///
Did you know that there is a newsgroup
Microsoft.public.dotnet.languages.vb

There you can get a lot of methods for this (I took the most simple one)

Keep in mind that in dotNet windowforms every control can have his own
controlcollection, so when this is on a frame you have not to say "me",
however "frame1" or whatever.

I hope this helps?

Cor

Nov 22 '05 #2
thanks and sorry for posting in the wrong forum

Nov 22 '05 #3
Filip,

Was no message to tell you that this is the wrong forum, only to tell you
that there is in my opinon a better one than this for the question you had
and you want to know more of it.

Maybe I had answered that as well in that newsgroup, however there are more
who can answer the question than here

(Although before someone understand it wrong I am not the only one here who
can answer your question).

Cor
thanks and sorry for posting in the wrong forum


Nov 22 '05 #4
thanks and sorry for posting in the wrong forum

Nov 22 '05 #5
Filip,

Was no message to tell you that this is the wrong forum, only to tell you
that there is in my opinon a better one than this for the question you had
and you want to know more of it.

Maybe I had answered that as well in that newsgroup, however there are more
who can answer the question than here

(Although before someone understand it wrong I am not the only one here who
can answer your question).

Cor
thanks and sorry for posting in the wrong forum


Nov 22 '05 #6
If these fields are really columns in a database, then you can effectively
still use the same technique, since the indexer on a dataset column is the
name of the field.

However, if these fields are actually variable names, you cannot do this
easily, and you may want to look at other schemes to index your values (like
an array).

Can you tell us if the "fields" are database columns or variables?

--- Nick
"Filip De Backer" <fi*************@hotmail.com.(donotspam)> wrote in message
news:52**********************************@microsof t.com...
Hi everybody,

I want something like I used in MS Access:

for i = 1 to 20
me("FieldName" & i).Text = "Text bla bla bla"
next i

I want something like that because I have a series of fields like
FieldName1; FieldName2, FieldName3, ... which I want to fill in
programmaticaly.

thanks in advance

Filip

Nov 22 '05 #7
why do you think that this is the wrong forum? Is this not a .net question?

"Filip De Backer" <fi*************@hotmail.com.(donotspam)> wrote in message
news:CF**********************************@microsof t.com...
thanks and sorry for posting in the wrong forum

Nov 22 '05 #8
If these fields are really columns in a database, then you can effectively
still use the same technique, since the indexer on a dataset column is the
name of the field.

However, if these fields are actually variable names, you cannot do this
easily, and you may want to look at other schemes to index your values (like
an array).

Can you tell us if the "fields" are database columns or variables?

--- Nick
"Filip De Backer" <fi*************@hotmail.com.(donotspam)> wrote in message
news:52**********************************@microsof t.com...
Hi everybody,

I want something like I used in MS Access:

for i = 1 to 20
me("FieldName" & i).Text = "Text bla bla bla"
next i

I want something like that because I have a series of fields like
FieldName1; FieldName2, FieldName3, ... which I want to fill in
programmaticaly.

thanks in advance

Filip

Nov 22 '05 #9
why do you think that this is the wrong forum? Is this not a .net question?

"Filip De Backer" <fi*************@hotmail.com.(donotspam)> wrote in message
news:CF**********************************@microsof t.com...
thanks and sorry for posting in the wrong forum

Nov 22 '05 #10
These fields are labels on the webform.
Sometimes i have 3 records of data, somtimes1, so I want to fill in the
labels by numbering them....
Nov 22 '05 #11
Filip De Backer <fi*************@hotmail.com.> wrote:
These fields are labels on the webform.
Sometimes i have 3 records of data, somtimes1, so I want to fill in the
labels by numbering them....


The easiest way is to have an array (or a map) of controls, rather than
have different actual fields.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #12
Filip,

A webform needs a little different approach than a windowform, keep my
sample I showed you in the earlier message. However use as well an old
sample of my, to set the textboxes on a form to space. (When it is not
directly on a form however on a panel, it needs the approach which is the
same as in a windowsform)

I hope this helps?

Cor

\\\
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim frm As Control = Me.FindControl("Form1")
Dim ctl As Control
For Each ctl In frm.Controls
Dim tb As TextBox
If TypeOf ctl Is TextBox Then
tb = DirectCast(ctl, TextBox)
tb.Text = String.Empty
End If
Next
///

These fields are labels on the webform.
Sometimes i have 3 records of data, somtimes1, so I want to fill in the
labels by numbering them....

Nov 22 '05 #13

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

Similar topics

0
by: Sue Adams | last post by:
I actually have two issues/questions: I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db. The code I use to get...
0
by: Ed | last post by:
Hello, I posted a question about looping with Select in a While loop, a few days ago. Repliers to my post advised me that a Cursor would be much better (thanks all for your replies). I found...
1
by: Earl Anderson | last post by:
I have imported an Excel worksheet into A97/WinXPH which had the new employees names in one field ( in a Last Name,First Name configuration). I wanted to split that one field ( ) into two...
1
by: Mal | last post by:
Hello. I have inherited a badly designed database and am trying to improve it. It is basically a flat file for survey results. one table holds, Name, Age etc as well as a field for each...
0
by: wjer | last post by:
I am trying to do two things for a test app: 1) Populate a CheckboxList webcontrol by loading a list of subject names (for the DataTextField) and subject codes (for the DataValueField). 2)...
4
by: just.an.imbecile | last post by:
I have searched alot for this and cannot find an answer. I have a simple form, and when it submits, I have it posting the data. I have a simple function to loop through and print out all my form...
6
by: Dave G | last post by:
I am writing a function to fill in the data in an unbound form. I have a table with field names of 1, 2, 3 etc up to approx 100. I have an unbound form with fields called 1, 2 3 etc. I gave...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
8
by: Kandar7272 | last post by:
Hi - I'm trying to work out a way to loop through (or just get a list of) all of the tables in an SQL Server (2005) database from Access. Based on the name of the table, I will then proceed to do...
3
by: eDaddi | last post by:
I can't figure out why I cant get this simple loop to work. I'm using it to validate a form. I thought I could put the required field names in an array, loop through the array and have the it check...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...

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.