471,570 Members | 936 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

length of variable

Hi
I am writing a short app that will collect some information and produce a
text file based on that information.

One of the values that goes into this text box must be max of 8 characters
long - otherwise it should be truncated to 8.

I used a statement based on if the length is > 8 then substring it to 8 but
i couldnt get the code to work.

Could someone please give me an example? The input is in a text box called
tbName.

thanks

Doug
Feb 23 '06 #1
2 1603
Why not post your code that does this and let us tell you what's wrong with
it?

Pete

"gordon" <go**********@optusnet.com.au> wrote in message
news:43**********************@news.optusnet.com.au ...
Hi
I am writing a short app that will collect some information and produce a
text file based on that information.

One of the values that goes into this text box must be max of 8 characters
long - otherwise it should be truncated to 8.

I used a statement based on if the length is > 8 then substring it to 8
but i couldnt get the code to work.

Could someone please give me an example? The input is in a text box
called tbName.

thanks

Doug

Feb 23 '06 #2
> Hi
I am writing a short app that will collect some information and produce a
text file based on that information.

One of the values that goes into this text box must be max of 8 characters
long - otherwise it should be truncated to 8.

I used a statement based on if the length is > 8 then substring it to 8 but i
couldnt get the code to work.

Could someone please give me an example? The input is in a text box called
tbName.

thanks

Doug


Are you by any chance trying

tbName.Text.Substring(0, 8);

then try this:

tbName.Text = tbName.Text.Substring(0, 8);
(explanation: strings are immutable, the various methods on string
don't modify the existing string but return a new, modified one)

Hans Kesting
Feb 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by dam_fool_2003 | last post: by
18 posts views Thread by Panchal V | last post: by
14 posts views Thread by Luiz Antonio Gomes Pican?o | last post: by
1 post views Thread by Guadala Harry | last post: by
2 posts views Thread by Frank Swarbrick | last post: by
13 posts views Thread by lak | last post: by
7 posts views Thread by Cromulent | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.