|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to write ?some same controls, the IDE will paste a assay control such as "label1(1),label1(2)......" . So I can control them total with the "for .....Next". But in VB.net When I do the same thing ,IDE will give me such as "label1,label2......". then how can I do as the VB6? for example: In VB6 Private Sub Form1_Load For i = 1 To 5 TextBox1(i) = "" Nex End Sub In VB.net I just can write as follow: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" End Sub How can I wirte in VB.net with "for next"?? Thanks a Lot!! Simon Unfortunately for all of us control array were scrapped int .NET.
However a few searches on this newsgroup or on MSDN will show ways to mimic control arrays. But to answer your question try out the below code. Be warned that the code can lead to runtime errors if you're not careful typing, and can be difficult to maintain. Dim i As Integer For i = 1 To 5 Me.Controls("TextBox" & i).Text = "" Next i Thanks, Seth Rowe simon wrote: Show quoteHide quote > Hi! I am beginner of VB.net When I wrote with VB6, I copy and paste > some same controls, the IDE will paste a assay control such as > "label1(1),label1(2)......" . So I can control them total with the "for > ....Next". > But in VB.net When I do the same thing ,IDE will give me such as > "label1,label2......". then how can I do as the VB6? > for example: > In VB6 > > Private Sub Form1_Load > For i = 1 To 5 > TextBox1(i) = "" > Nex > End Sub > > In VB.net I just can write as follow: > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load > Dim i As Integer > TextBox1.Text = "" > TextBox2.Text = "" > TextBox3.Text = "" > TextBox4.Text = "" > TextBox5.Text = "" > > End Sub > > How can I wirte in VB.net with "for next"?? > > Thanks a Lot!! > > Simon Rowe,
> Unfortunately for all of us control array were scrapped int .NET. This is often misinterpreted in my opinion. There is not any more the designer part of VB6 with the control properties. There are now more control arrays in Net as there have ever been in VB6, while mimic that array in even a better way is very easy \\\. Dim MySpecialControls() As Control = {Button1, TextBox1} For Each ctr As Control In MySpecialControls ctr.Text = "Hello" Next /// But this is only one of the it seems now endless possibilities to use conrol arrays in .Net. I hope this gives an idea, Cor Show quoteHide quote "rowe_newsgroups" <rowe_em***@yahoo.com> schreef in bericht news:1157895302.882824.42110@e3g2000cwe.googlegroups.com... > Unfortunately for all of us control array were scrapped int .NET. > However a few searches on this newsgroup or on MSDN will show ways to > mimic control arrays. But to answer your question try out the below > code. Be warned that the code can lead to runtime errors if you're not > careful typing, and can be difficult to maintain. > > Dim i As Integer > > For i = 1 To 5 > Me.Controls("TextBox" & i).Text = "" > Next i > > Thanks, > > Seth Rowe > > simon wrote: >> Hi! I am beginner of VB.net When I wrote with VB6, I copy and paste >> some same controls, the IDE will paste a assay control such as >> "label1(1),label1(2)......" . So I can control them total with the "for >> ....Next". >> But in VB.net When I do the same thing ,IDE will give me such as >> "label1,label2......". then how can I do as the VB6? >> for example: >> In VB6 >> >> Private Sub Form1_Load >> For i = 1 To 5 >> TextBox1(i) = "" >> Nex >> End Sub >> >> In VB.net I just can write as follow: >> >> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As >> System.EventArgs) Handles MyBase.Load >> Dim i As Integer >> TextBox1.Text = "" >> TextBox2.Text = "" >> TextBox3.Text = "" >> TextBox4.Text = "" >> TextBox5.Text = "" >> >> End Sub >> >> How can I wirte in VB.net with "for next"?? >> >> Thanks a Lot!! >> >> Simon > Cor Ligthert [MVP] wrote:
Show quoteHide quote > Rowe, > > > Unfortunately for all of us control array were scrapped int .NET. > > This is often misinterpreted in my opinion. There is not any more the > designer part of VB6 with the control properties. > > There are now more control arrays in Net as there have ever been in VB6, > while mimic that array in even a better way is very easy > \\\. > Dim MySpecialControls() As Control = {Button1, TextBox1} > For Each ctr As Control In MySpecialControls > ctr.Text = "Hello" > Next > /// > > But this is only one of the it seems now endless possibilities to use conrol > arrays in .Net. > > I hope this gives an idea, > > Cor > > > > "rowe_newsgroups" <rowe_em***@yahoo.com> schreef in bericht > news:1157895302.882824.42110@e3g2000cwe.googlegroups.com... > > Unfortunately for all of us control array were scrapped int .NET. > > However a few searches on this newsgroup or on MSDN will show ways to > > mimic control arrays. But to answer your question try out the below > > code. Be warned that the code can lead to runtime errors if you're not > > careful typing, and can be difficult to maintain. > > > > Dim i As Integer > > > > For i = 1 To 5 > > Me.Controls("TextBox" & i).Text = "" > > Next i > > > > Thanks, > > > > Seth Rowe > > > > simon wrote: > >> Hi! I am beginner of VB.net When I wrote with VB6, I copy and paste > >> some same controls, the IDE will paste a assay control such as > >> "label1(1),label1(2)......" . So I can control them total with the "for > >> ....Next". > >> But in VB.net When I do the same thing ,IDE will give me such as > >> "label1,label2......". then how can I do as the VB6? > >> for example: > >> In VB6 > >> > >> Private Sub Form1_Load > >> For i = 1 To 5 > >> TextBox1(i) = "" > >> Nex > >> End Sub > >> > >> In VB.net I just can write as follow: > >> > >> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > >> System.EventArgs) Handles MyBase.Load > >> Dim i As Integer > >> TextBox1.Text = "" > >> TextBox2.Text = "" > >> TextBox3.Text = "" > >> TextBox4.Text = "" > >> TextBox5.Text = "" > >> > >> End Sub > >> > >> How can I wirte in VB.net with "for next"?? > >> > >> Thanks a Lot!! > >> > >> Simon > > rowe_newsgroups wrote:
Show quoteHide quote > Unfortunately for all of us control array were scrapped int .NET. > However a few searches on this newsgroup or on MSDN will show ways to > mimic control arrays. But to answer your question try out the below > code. Be warned that the code can lead to runtime errors if you're not > careful typing, and can be difficult to maintain. > > Dim i As Integer > > For i = 1 To 5 > Me.Controls("TextBox" & i).Text = "" > Next i > > Thanks, > > Seth Rowe > > simon wrote: > > Hi! I am beginner of VB.net When I wrote with VB6, I copy and paste > > some same controls, the IDE will paste a assay control such as > > "label1(1),label1(2)......" . So I can control them total with the "for > > ....Next". > > But in VB.net When I do the same thing ,IDE will give me such as > > "label1,label2......". then how can I do as the VB6? > > for example: > > In VB6 > > > > Private Sub Form1_Load > > For i = 1 To 5 > > TextBox1(i) = "" > > Nex > > End Sub > > > > In VB.net I just can write as follow: > > > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load > > Dim i As Integer > > TextBox1.Text = "" > > TextBox2.Text = "" > > TextBox3.Text = "" > > TextBox4.Text = "" > > TextBox5.Text = "" > > > > End Sub > > > > How can I wirte in VB.net with "for next"?? > > > > Thanks a Lot!! > > > > Simon "simon" <spain***@gmail.com> schrieb: Accessing controls by their names or indices> When I wrote with VB6, I copy and paste > some same controls, the IDE will paste a assay control such as > "label1(1),label1(2)......" . So I can control them total with the "for > ....Next". > But in VB.net When I do the same thing ,IDE will give me such as > "label1,label2......". then how can I do as the VB6? <URL:http://dotnet.mvps.org/dotnet/faqs/?id=controlbynameindex&lang=en> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
How can I make a copy of my collection?
Difference in using "With Me" statement in dotnet VB and access VBA DownloadComplete HEX char -- > its comlement naive question Event Monitoring. Bit and boolean Refresh DataGrid XML Comments in a namespace How do I paint the combo box dropdown button in a datagridview column |
|||||||||||||||||||||||