String Manipulation 
Author Message
 String Manipulation

Hi,

I am adding a series of characters to a string, and in a certain
instance, I need to delete some characters.

E.g. If I have a Label, and its contents = "F1-F2-F3", how can I
delete the last 3 characters programatically so it will equal "F1-F2".
The thing is, it may be varying lengths, an in certain circumstances,
I will want to delete the last 3 characters, no matter how long the
string is.

Many thanks in advance.

Regards,

David.



Sun, 27 Nov 2005 14:21:54 GMT  
 String Manipulation
dim a as string
a  = a.substring(0, a.length-3)
you can do it too VB6 and before style
a = Mid(a,1,(Len(a)-3))
I prefer the first one because that is the same way you do it in C## and
Java and others



Quote:
> Hi,

> I am adding a series of characters to a string, and in a certain
> instance, I need to delete some characters.

> E.g. If I have a Label, and its contents = "F1-F2-F3", how can I
> delete the last 3 characters programatically so it will equal "F1-F2".
> The thing is, it may be varying lengths, an in certain circumstances,
> I will want to delete the last 3 characters, no matter how long the
> string is.

> Many thanks in advance.

> Regards,

> David.



Sun, 27 Nov 2005 14:59:04 GMT  
 String Manipulation
Hi, assuming Label1 is your label:

Label1.Text = Label1.Text.Substring(0, Label1.Text.Length - 3)

--
Happy to help,
-- Tom Spink

Please respond to the newsgroup,
so all can benefit.

One Day,

Quote:
> Hi,

> I am adding a series of characters to a string, and in a certain
> instance, I need to delete some characters.

> E.g. If I have a Label, and its contents = "F1-F2-F3", how can I
> delete the last 3 characters programatically so it will equal "F1-F2".
> The thing is, it may be varying lengths, an in certain circumstances,
> I will want to delete the last 3 characters, no matter how long the
> string is.

> Many thanks in advance.

> Regards,

> David.



Sun, 27 Nov 2005 18:40:54 GMT  
 String Manipulation
Thanks for your help! My brain turned to mush and I couldn't get my head around it!

Regards,

David.

Quote:

> Hi, assuming Label1 is your label:

> Label1.Text = Label1.Text.Substring(0, Label1.Text.Length - 3)

> --
> Happy to help,
> -- Tom Spink

> Please respond to the newsgroup,
> so all can benefit.

> One Day,


> > Hi,

> > I am adding a series of characters to a string, and in a certain
> > instance, I need to delete some characters.

> > E.g. If I have a Label, and its contents = "F1-F2-F3", how can I
> > delete the last 3 characters programatically so it will equal "F1-F2".
> > The thing is, it may be varying lengths, an in certain circumstances,
> > I will want to delete the last 3 characters, no matter how long the
> > string is.

> > Many thanks in advance.

> > Regards,

> > David.



Mon, 28 Nov 2005 07:01:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. string manipulation, string routines, etc.

2. String manipulation

3. String Manipulation

4. VBA String Manipulation DLL Missing

5. String manipulation in VBA

6. String manipulation with vbscript

7. String manipulation topic

8. String manipulation...

9. Text String Manipulation

10. Newbie question : string manipulation with VBscript.

11. String manipulation

12. String manipulation

 

 
Powered by phpBB® Forum Software