Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am retrieving some product information from database in character format & i need to display only starting 50 words of that information..
Posted
Updated 26-Jan-14 22:12pm
v2

Look into the Substring function.

http://www.dotnetperls.com/substring-vbnet[^]

All you need to to is yourstring.Substring(0, 50);
 
Share this answer
 
Comments
ashishtanwar88 27-Jan-14 5:41am    
Initial i was using that information in character (starting 200 characters) but in some cases last word not full displaying.

example :

"In an attempt to facilitate the learning process of students, the book aims at bringing out the conceptual aspects of biochemistry in a magnified view with a complete picture of the context in a diffe"

Last word is difference but it showing only "diffe" because 200 characters limit finished. this issue i need to resolve. I want end of given information with complete word.

I am using sql 2005 with vs 2008. i am retrieving this information from a table named as Book_Information and the column name is Overview.

My current code is :
Dim Bkdesc as String
Bkdesc = RsProdesc("Overview")
Bkdesc = Bkdesc.Substring(0, 200)
I have solved this myself by using following code:

Dim Bkdesc as String

Bkdesc = RsProdesc("Overview")
Bkdesc = Bkdesc.Substring(0,200)
Dim LsI As Integer
LsI = Bkdesc.LastIndexOf(" ")
Bkdesc = Bkdesc.Substring(0, LsI)

& Thanks all of you..
 
Share this answer
 
v2
Usually you would implement the 50 character limitation when retrieving the product information from your database.
As you haven't told us what database system you are using, we can't help you do this.

To do this in VB.NET, have a look at the Left function.
It will enable you to display on a certain amount of characters.
 
Share this answer
 
Comments
ashishtanwar88 27-Jan-14 5:25am    
Initial i was using that information in character (starting 200 characters) but in some cases last word not full displaying.

example :

"In an attempt to facilitate the learning process of students, the book aims at bringing out the conceptual aspects of biochemistry in a magnified view with a complete picture of the context in a diffe"

Last word is difference but it showing only "diffe" because 200 characters limit finished. this issue i need to resolve. I want end of given information with complete word.

I am using sql 2005 with vs 2008. i am retrieving this information from a table named as Book_Information and the column name is Overview.

My current code is :

Dim Bkdesc as String

Bkdesc = RsProdesc("Overview")
Bkdesc = Bkdesc.Substring(0, 200)
hypermellow 27-Jan-14 5:51am    
Have a look at:
http://stackoverflow.com/questions/15909143/use-substring-and-charindex-to-get-last-complete-word-in-field

... it should get you started.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900