Length of a string

G

Guest

Hi all

I need the length of string. If the string is longer than my button I need to cut it. What is the best solution to find this?

Thank
George
 
D

Dan

Dim strMyString As String
Dim intLength As Integer

intLength = strMyString.Length

George W. said:
Hi all,

I need the length of string. If the string is longer than my button I need
to cut it. What is the best solution to find this??
 
K

Kevin Spencer

String.Length

Example:

Dim s As String = "Hello"
Dim i As Integer = s.Length

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

George W. said:
Hi all,

I need the length of string. If the string is longer than my button I need
to cut it. What is the best solution to find this??
 
D

DalePres

Look up the MeasureString method of the Graphics class. There are a lot of
examples in the Framework SDK documentation. That will give you a SizeF
object describing height and width of the string.

Dale

George W. said:
Hi all,

I need the length of string. If the string is longer than my button I need
to cut it. What is the best solution to find this??
 
B

bruce barker

using the graphics lib won't work, as the measuring is done on the server,
which may not have the same font size, or screen resolution as the client.
this can only be accurately on the client.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,260
Messages
2,571,039
Members
48,768
Latest member
first4landlord

Latest Threads

Top