|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
need help with a string manipulation.I am trying to create few dynamic controls and once they are rendered I need to save the information that was entered into these dynamic fileds. For instance when I create 3 radio button dynamic controls I get the ID of this controls as rdb29OPT0 rdb30OPT1 rdb31OPT2 .... Now I am trying to manipulate the the above string and just try getting the 29, 30, 31 from them. Can some one help me with how do I just the values 29 and remove rdbOPT1 for the first string? Thanks in advance -L Take a look at the "mid" funtion.
Ahmed Learner wrote: Show quoteHide quote > Hello, > I am trying to create few dynamic controls and once they are rendered > I need to save the information that was entered into these dynamic > fileds. > > For instance when I create 3 radio button dynamic controls I get the ID > of this controls as > > rdb29OPT0 > rdb30OPT1 > rdb31OPT2 > ... > > Now I am trying to manipulate the the above string and just try getting > the 29, 30, 31 from them. Can some one help me with how do I just the > values 29 and remove rdbOPT1 for the first string? > > Thanks in advance > -L
Show quote
Hide quote
"Ahmed" <ahmed1***@gmail.com> wrote in message And without using the VisualBasic namespace (my preference, not required) news:1151596865.645830.139100@d56g2000cwd.googlegroups.com... > Take a look at the "mid" funtion. > > Ahmed > Learner wrote: >> Hello, >> I am trying to create few dynamic controls and once they are rendered >> I need to save the information that was entered into these dynamic >> fileds. >> >> For instance when I create 3 radio button dynamic controls I get the ID >> of this controls as >> >> rdb29OPT0 >> rdb30OPT1 >> rdb31OPT2 >> ... >> >> Now I am trying to manipulate the the above string and just try getting >> the 29, 30, 31 from them. Can some one help me with how do I just the >> values 29 and remove rdbOPT1 for the first string? >> >> Thanks in advance >> -L > using using the static (Shared in Visual Basic) Substring method: Dim s As String = "rdb290PT0" Dim n As String = s.Substring(3, 2) HTH Mythran well there could be many values down the line for instance
rdb1234OPT1234 ! out of which I just need the numerical value that is in between 'rdb' and 'OPT1234' I am looking for kind of a method that could rdb and also the word that starts with OPT Hope this gives a little inside of it. Thanks -L Mythran wrote: Show quoteHide quote > "Ahmed" <ahmed1***@gmail.com> wrote in message > news:1151596865.645830.139100@d56g2000cwd.googlegroups.com... > > Take a look at the "mid" funtion. > > > > Ahmed > > Learner wrote: > >> Hello, > >> I am trying to create few dynamic controls and once they are rendered > >> I need to save the information that was entered into these dynamic > >> fileds. > >> > >> For instance when I create 3 radio button dynamic controls I get the ID > >> of this controls as > >> > >> rdb29OPT0 > >> rdb30OPT1 > >> rdb31OPT2 > >> ... > >> > >> Now I am trying to manipulate the the above string and just try getting > >> the 29, 30, 31 from them. Can some one help me with how do I just the > >> values 29 and remove rdbOPT1 for the first string? > >> > >> Thanks in advance > >> -L > > > > And without using the VisualBasic namespace (my preference, not required) > using using the static (Shared in Visual Basic) Substring method: > > Dim s As String = "rdb290PT0" > Dim n As String = s.Substring(3, 2) > > > HTH > Mythran I noticed that the number at the end is the same as the number in the
middle. To get the value in at the end you can use the following: s.Substring(s.IndexOf("OPT") + 3) And if you want the number in the middle you can use the following: s.Substring(3, s.IndexOf("OPT") - 3) Learner wrote: Show quoteHide quote > well there could be many values down the line for instance > rdb1234OPT1234 ! > out of which I just need the numerical value that is in between 'rdb' > and 'OPT1234' > > I am looking for kind of a method that could rdb and also the word that > starts with OPT > > Hope this gives a little inside of it. > Thanks > -L > Mythran wrote: > > "Ahmed" <ahmed1***@gmail.com> wrote in message > > news:1151596865.645830.139100@d56g2000cwd.googlegroups.com... > > > Take a look at the "mid" funtion. > > > > > > Ahmed > > > Learner wrote: > > >> Hello, > > >> I am trying to create few dynamic controls and once they are rendered > > >> I need to save the information that was entered into these dynamic > > >> fileds. > > >> > > >> For instance when I create 3 radio button dynamic controls I get the ID > > >> of this controls as > > >> > > >> rdb29OPT0 > > >> rdb30OPT1 > > >> rdb31OPT2 > > >> ... > > >> > > >> Now I am trying to manipulate the the above string and just try getting > > >> the 29, 30, 31 from them. Can some one help me with how do I just the > > >> values 29 and remove rdbOPT1 for the first string? > > >> > > >> Thanks in advance > > >> -L > > > > > > > And without using the VisualBasic namespace (my preference, not required) > > using using the static (Shared in Visual Basic) Substring method: > > > > Dim s As String = "rdb290PT0" > > Dim n As String = s.Substring(3, 2) > > > > > > HTH > > Mythran Hello Ahmed,
Thanks for the help. s.Substring(3, s.IndexOf("OPT") - 3) works in my case. I didn't know that I can use the IndexOf to get the exact position of particular charecter in a string. Thats what I was looking for. thanks again, -L Ahmed wrote: Show quoteHide quote > I noticed that the number at the end is the same as the number in the > middle. To get the value in at the end you can use the following: > > s.Substring(s.IndexOf("OPT") + 3) > > And if you want the number in the middle you can use the following: > s.Substring(3, s.IndexOf("OPT") - 3) > > Learner wrote: > > well there could be many values down the line for instance > > rdb1234OPT1234 ! > > out of which I just need the numerical value that is in between 'rdb' > > and 'OPT1234' > > > > I am looking for kind of a method that could rdb and also the word that > > starts with OPT > > > > Hope this gives a little inside of it. > > Thanks > > -L > > Mythran wrote: > > > "Ahmed" <ahmed1***@gmail.com> wrote in message > > > news:1151596865.645830.139100@d56g2000cwd.googlegroups.com... > > > > Take a look at the "mid" funtion. > > > > > > > > Ahmed > > > > Learner wrote: > > > >> Hello, > > > >> I am trying to create few dynamic controls and once they are rendered > > > >> I need to save the information that was entered into these dynamic > > > >> fileds. > > > >> > > > >> For instance when I create 3 radio button dynamic controls I get the ID > > > >> of this controls as > > > >> > > > >> rdb29OPT0 > > > >> rdb30OPT1 > > > >> rdb31OPT2 > > > >> ... > > > >> > > > >> Now I am trying to manipulate the the above string and just try getting > > > >> the 29, 30, 31 from them. Can some one help me with how do I just the > > > >> values 29 and remove rdbOPT1 for the first string? > > > >> > > > >> Thanks in advance > > > >> -L > > > > > > > > > > And without using the VisualBasic namespace (my preference, not required) > > > using using the static (Shared in Visual Basic) Substring method: > > > > > > Dim s As String = "rdb290PT0" > > > Dim n As String = s.Substring(3, 2) > > > > > > > > > HTH > > > Mythran You are welcome :)
Learner wrote: Show quoteHide quote > Hello Ahmed, > Thanks for the help. s.Substring(3, s.IndexOf("OPT") - 3) works in > my case. I didn't know that I can use the IndexOf to get the exact > position of particular charecter in a string. Thats what I was looking > for. > > thanks again, > -L > > Ahmed wrote: > > I noticed that the number at the end is the same as the number in the > > middle. To get the value in at the end you can use the following: > > > > s.Substring(s.IndexOf("OPT") + 3) > > > > And if you want the number in the middle you can use the following: > > s.Substring(3, s.IndexOf("OPT") - 3) > > > > Learner wrote: > > > well there could be many values down the line for instance > > > rdb1234OPT1234 ! > > > out of which I just need the numerical value that is in between 'rdb' > > > and 'OPT1234' > > > > > > I am looking for kind of a method that could rdb and also the word that > > > starts with OPT > > > > > > Hope this gives a little inside of it. > > > Thanks > > > -L > > > Mythran wrote: > > > > "Ahmed" <ahmed1***@gmail.com> wrote in message > > > > news:1151596865.645830.139100@d56g2000cwd.googlegroups.com... > > > > > Take a look at the "mid" funtion. > > > > > > > > > > Ahmed > > > > > Learner wrote: > > > > >> Hello, > > > > >> I am trying to create few dynamic controls and once they are rendered > > > > >> I need to save the information that was entered into these dynamic > > > > >> fileds. > > > > >> > > > > >> For instance when I create 3 radio button dynamic controls I get the ID > > > > >> of this controls as > > > > >> > > > > >> rdb29OPT0 > > > > >> rdb30OPT1 > > > > >> rdb31OPT2 > > > > >> ... > > > > >> > > > > >> Now I am trying to manipulate the the above string and just try getting > > > > >> the 29, 30, 31 from them. Can some one help me with how do I just the > > > > >> values 29 and remove rdbOPT1 for the first string? > > > > >> > > > > >> Thanks in advance > > > > >> -L > > > > > > > > > > > > > And without using the VisualBasic namespace (my preference, not required) > > > > using using the static (Shared in Visual Basic) Substring method: > > > > > > > > Dim s As String = "rdb290PT0" > > > > Dim n As String = s.Substring(3, 2) > > > > > > > > > > > > HTH > > > > Mythran You might want to look into usign a RegularExpression.Matches() method in
that case. There are plenty of tutorials on RegEx available. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx Show quoteHide quote > well there could be many values down the line for instance > rdb1234OPT1234 ! > out of which I just need the numerical value that is in between 'rdb' > and 'OPT1234' > I am looking for kind of a method that could rdb and also the word > that starts with OPT Mythran wrote:
> And without using the VisualBasic namespace (my preference, not required) Substring is not a Shared member, it is an instance member.> using using the static (Shared in Visual Basic) Substring method: > > Dim s As String = "rdb290PT0" > Dim n As String = s.Substring(3, 2) "Chris Dunaway" <dunaw***@gmail.com> wrote in message Woops :) I knew that too...don't know why .. at the time .. I thought it news:1151600325.693519.241350@j72g2000cwa.googlegroups.com... > Mythran wrote: >> And without using the VisualBasic namespace (my preference, not required) >> using using the static (Shared in Visual Basic) Substring method: >> >> Dim s As String = "rdb290PT0" >> Dim n As String = s.Substring(3, 2) > > Substring is not a Shared member, it is an instance member. > was static lol :P I stand corrected (not the first time, nor the last, at least it was a little help in the right direction). Mythran Hello Learner,
Regex is overkill and overly complex. Why not just store the number in the control's .Tag property. Or derive a new control from radiobutton and add a .Identifier property. -Boo Show quoteHide quote > Hello, > I am trying to create few dynamic controls and once they are > rendered > I need to save the information that was entered into these dynamic > fileds. > > For instance when I create 3 radio button dynamic controls I get the > ID of this controls as > > rdb29OPT0 > rdb30OPT1 > rdb31OPT2 > ... > Now I am trying to manipulate the the above string and just try > getting the 29, 30, 31 from them. Can some one help me with how do I > just the values 29 and remove rdbOPT1 for the first string? > > Thanks in advance > -L
+ and & operators
Threads do not Terminate! a simply VB.net/ SQL SERVER question OpenFileDialog Handle Leak read textbox into array - vb2005 DataGridView Question - VB.NET 2005 REGULAR EXPRESSION extract a word and text around it change cursor to hourglass (WaitCursor) between try..catch VB.net Express compiling problems GetPrivateProfileString problem! |
|||||||||||||||||||||||