473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Limit the size of string

Hi,

Is there any easy way to limit the size of the string?

I have

Private msDescription As String

I want to limit the msDescription to 50 instead of unlimitted.

I wish I could do something like

Private msDescription As String(50)

How to achive this?

Thanks
Nov 20 '05 #1
5 2460
You could make a property of type string, then in the accessor verify its
length and either throw an exception or just disallow it.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Sehboo" <ma*********@hotmail.com> wrote in message
news:7b**************************@posting.google.c om...
Hi,

Is there any easy way to limit the size of the string?

I have

Private msDescription As String

I want to limit the msDescription to 50 instead of unlimitted.

I wish I could do something like

Private msDescription As String(50)

How to achive this?

Thanks

Nov 20 '05 #2
You can use a StringBuilder object instead of a String.
Here's a nice explanation:

Dim x as New StringBuilder(50,50) 'Creates a string builder with 50
characters and a maximum of 50 characters
x.Append("Hello") ' Appends data to x

Telmo Sampaio

"Sehboo" <ma*********@hotmail.com> wrote in message
news:7b**************************@posting.google.c om...
Hi,

Is there any easy way to limit the size of the string?

I have

Private msDescription As String

I want to limit the msDescription to 50 instead of unlimitted.

I wish I could do something like

Private msDescription As String(50)

How to achive this?

Thanks

Nov 20 '05 #3
Hi,

<VBFixedString(50)> Dim msDescription As String

Ken

----------------------

"Sehboo" <ma*********@hotmail.com> wrote in message
news:7b**************************@posting.google.c om...
Hi,

Is there any easy way to limit the size of the string?

I have

Private msDescription As String

I want to limit the msDescription to 50 instead of unlimitted.

I wish I could do something like

Private msDescription As String(50)

How to achive this?

Thanks

Nov 20 '05 #4
* ma*********@hotmail.com (Sehboo) scripsit:
Is there any easy way to limit the size of the string?

I have

Private msDescription As String

I want to limit the msDescription to 50 instead of unlimitted.

I wish I could do something like

Private msDescription As String(50)

How to achive this?


Just FMI: Why? As you are responsible for assigning something to the
string, you can easily check the length before assinging something.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
Hi Sehboo.

Private myDescription as String
Private msDescription As String

myDescription = msDescription.substring(0,50)

I hope this helps,

Cor
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: steve | last post by:
I am setting up a huge database in mysql, and I get the above error in Linux. I believe it is related to the size of one of my tables, which is 4,294,966,772 bytes in size. Can someone help. How...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
10
by: VM | last post by:
How can I limit the use of the PC's virtual memory? I'm running a process that basically takes a txt file and loads it to a datatable. The problem is that the file is over 400,000 lines long (77...
9
by: James Macbell | last post by:
I think I have pushed ASP.NET to the limit, I am not sure if I have done anything wrong in the code because I am trying to make 2 pieces of code (C# vs PHP) using the same algorithm. Anyways, here...
0
by: Burton Wilkins | last post by:
Dear Authorities: I realize that in communicating with a Web Service, one is essentially passing a string as a parameter. Is there a limit over the Internet how long a parameter string can be?...
5
by: Daniel | last post by:
c# string size limit? length of string limit?
1
by: Daniel | last post by:
is there any limit to how long of a string SqlDataReader.GetString() can return?
8
by: tshad | last post by:
Is there a string limit is C#? I have a Textbox that I am allowing users to paste into (can be a word document). But I am finding that I am losing data when I write large files to my Sql Server...
10
by: orsula | last post by:
Hi Guys, I have a class A composed of several string and int members. I would like to manage a huge amount (several thousands) of A objects in a dictionary where each object has its unique key....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.