Home All Groups Group Topic Archive Search About

need help with a string manipulation.

Author
29 Jun 2006 3:41 PM
Learner
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

Author
29 Jun 2006 4:01 PM
Ahmed
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
Author
29 Jun 2006 4:06 PM
Mythran
Show quote Hide 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
Author
29 Jun 2006 4:30 PM
Learner
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
Author
29 Jun 2006 5:03 PM
Ahmed
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
Author
30 Jun 2006 1:23 PM
Learner
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
Author
30 Jun 2006 1:34 PM
Ahmed
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
Author
29 Jun 2006 5:10 PM
Jim Wooley
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
Author
29 Jun 2006 4:58 PM
Chris Dunaway
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.
Author
29 Jun 2006 8:19 PM
Mythran
"Chris Dunaway" <dunaw***@gmail.com> wrote in message
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.
>

Woops :)  I knew that too...don't know why .. at the time .. I thought it
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
Author
29 Jun 2006 6:09 PM
GhostInAK
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