473,800 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2478
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*********@ho tmail.com> wrote in message
news:7b******** *************** ***@posting.goo gle.com...
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(5 0,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*********@ho tmail.com> wrote in message
news:7b******** *************** ***@posting.goo gle.com...
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*********@ho tmail.com> wrote in message
news:7b******** *************** ***@posting.goo gle.com...
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*********@hot mail.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.s ubstring(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
6048
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 can I break that barrier. A google search did not turn up anything useful. -- Posted using the http://www.dbforumz.com interface, at author's request Articles individually checked for conformance to usenet standards
9
10850
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 LDIFDE as a comparison I get the same results. No members means just that, an empty group. Zero means that the DirectorySearcher.SizeLimit has been exceeded....
10
3837
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 MB) and after a while I get the Windows message saying that the virtual memory's getting really low. Plus the machine gets really sluggish (with multi-threading). Is it possible to use the virtual memory until it reaches a certain limit and then use...
9
1723
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 is the my test. How: Create a HTML page with 2 hyper links to these files (posted below). Right click, Save target As. Tested: On my P4 1.6 GHz , 1 GB Ram server, Windows 2000 IIS 5 and Apache 1.3 for win32, 100 Mbps LAN Sample Size: 150 MB...
0
3456
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? Or can the string be of an unlimited length, and is then simply divided up into packets? Is there a danger of loosing data if the string being passed in a parameter
5
5443
by: Daniel | last post by:
c# string size limit? length of string limit?
1
3392
by: Daniel | last post by:
is there any limit to how long of a string SqlDataReader.GetString() can return?
8
8318
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 database. The fields is set to text. The data is kept in an object in a "string" variable when I am moving from asp.net page to page. One example had the data at 23k, but when I got the data back, it only have
10
23792
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. Is there any known limitation or best practice that you think I should consider? Thanks,
0
10501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.