On a winform I have 30 text boxes, named txtType0 though txtType29.
An array to hold info, Dim infoType(29) as String,
I would like to assign the text in each text box to its corresponding
variable. I know there has to be a better way to do it than this.
infoType(0) = txtType0.Text
infoType(1) = txtType1.Text
infoType(2) = txtType2.Text
This is what I am trying but cant find a way to get it to work.
Sub looper()
Dim loopnumber As Integer
For loopnumber = 0 To 29
infoType(loopnumber) = txtType& loopnumber & .Text
'also tried = txtType & (loopnumber) & .Text and
other Combinations
Next loopnumber
End Sub
Thank you very much, any help will be greatly appreciated 5 941
"J. Freeman" <ja**@freemandirect.com> schrieb: On a winform I have 30 text boxes, named txtType0 though txtType29. An array to hold info, Dim infoType(29) as String, I would like to assign the text in each text box to its corresponding variable. I know there has to be a better way to do it than this. infoType(0) = txtType0.Text
infoType(1) = txtType1.Text
infoType(2) = txtType2.Text
\\\
Private m_TextBoxes() As TextBox
..
..
..
' In the form's constructor after the call to 'InitializeComponent'.
m_TextBoxes = _
{ _
Me.TextBox1, _
Me.TextBox2, _
... _
}
..
..
..
For i As Integer = 0 To m_TextBoxes.Length - 1
InfoType(i) = m_TextBoxes(i).Text
Next i
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
J,
Although I almost forever give the solution as Herfried does now as well, do
I think that in this case there can be an alternative that needs less typing
(not actual speed that is a little bit less however needs probably
milleniums to be able to see that)
When you have only your textboxes direct on one container, by instance the
form, than you can use as well something.
\\\Snippet typed in this message not tested.
for each ctr as control in me.controls
if ctr.name.substring(0,7) = "txtType" then
infoType(Cint(ctr.name.substring(7)) = ctr.text
end if
next
///
I hope this give more idea's
Cor
Humm
When I enter your example I get a syntax error on line:
m_TextBoxes = {Me.TextBox1, Me.TextBox2} "expression expected"
the first bracket is underlined
"Herfried K. Wagner [MVP]" wrote: "J. Freeman" <ja**@freemandirect.com> schrieb: On a winform I have 30 text boxes, named txtType0 though txtType29. An array to hold info, Dim infoType(29) as String, I would like to assign the text in each text box to its corresponding variable. I know there has to be a better way to do it than this. infoType(0) = txtType0.Text
infoType(1) = txtType1.Text
infoType(2) = txtType2.Text
\\\ Private m_TextBoxes() As TextBox .. .. ..
' In the form's constructor after the call to 'InitializeComponent'. m_TextBoxes = _ { _ Me.TextBox1, _ Me.TextBox2, _ ... _ } .. .. .. For i As Integer = 0 To m_TextBoxes.Length - 1 InfoType(i) = m_TextBoxes(i).Text Next i ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
"mark" <ma**@discussions.microsoft.com> schrieb: When I enter your example I get a syntax error on line: m_TextBoxes = {Me.TextBox1, Me.TextBox2} "expression expected"
Sorry... 'm_TextBoxes = New TextBox() {Me.TextBox1, ...}'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thanks to all for the help I really appreciate it, got it to work both ways.
You have gotten me farther along with my program, but more importantly You
taught me stuff I could not find, or maybe did not understand from the
books. Again THANK YOU ALL SO MUCH.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ud****************@TK2MSFTNGP11.phx.gbl... J,
Although I almost forever give the solution as Herfried does now as well, do I think that in this case there can be an alternative that needs less typing (not actual speed that is a little bit less however needs probably milleniums to be able to see that)
When you have only your textboxes direct on one container, by instance the form, than you can use as well something.
\\\Snippet typed in this message not tested. for each ctr as control in me.controls if ctr.name.substring(0,7) = "txtType" then infoType(Cint(ctr.name.substring(7)) = ctr.text end if next ///
I hope this give more idea's
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kurt Watson |
last post by:
I’m having a different kind of problem with Hotmail when I sign in it
says, "Web Browser Software Limitations
Your Current Software Will Limit Your Ability to Use Hotmail
You are using a web...
|
by: x muzuo |
last post by:
Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
{////<<head>
<title>IIBO Submit Page</title>...
|
by: tyler_durden |
last post by:
thanks a lot for all your help..I'm really appreciated...
with all the help I've been getting in forums I've been able to continue
my program and it's almost done, but I'm having a big problem that...
|
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application...
|
by: Joner |
last post by:
Hello,
I'm having trouble with a little programme of mine where I connect to
an access database. It seems to connect fine, and disconnect fine, but
then after it won't reconnect, I get the error...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej...
|
by: PEB |
last post by:
POSTING GUIDELINES
Please follow these guidelines when posting questions
Post your question in a relevant forum
Do NOT PM questions to individual experts - This is not fair on them and...
|
by: 2Barter.net |
last post by:
newsmail@reuters.uk.ed10.net Fwd: Money for New Orleans, AL & GA
Inbox
Reply
Reply to all
Forward
Print
Add 2Barter.net to Contacts list
Delete this message
Report phishing
Show original
|
by: jenipriya |
last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors...
The table structures i hav
Employee (EmpID,...
|
by: tabani |
last post by:
I wrote the program and its not giving me correct answer can any one help me with that please and specify my mistake please it will be highly appreciable...
The error arrives from option 'a' it asks...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |