[dba-VB] VB.Net - cut and trim

JWColby jwcolby at colbyconsulting.com
Wed May 9 16:46:10 CDT 2007


Done.  Thanks guys. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Eric Barro
Sent: Wednesday, May 09, 2007 5:37 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] VB.Net - cut and trim

It would be the same syntax in VB.NET except you lose the ; at the end. :) 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Ron Allen
Sent: Wednesday, May 09, 2007 2:24 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] VB.Net - cut and trim

John,

In C#, you can do this in one line, no need to use the stringbuilder class:
	
output = recordValue.Substring(startPosition, resultWidth).Trim();

If the recordValue = "abcdefghijklmnop", startPosition = 5, and resultWidth
= 6, output would be "fghijk".

Ron




> I am looking at how to do in VB.Net what in VBA would be str = 
> trim(mid(str,intStartPos, intLen))
>  
> I can do this (I think) in two steps using:
>  
>     private mstr as string
>     mstr = lstrRecord.SubString(intStartPos,intWidth)
>     mstr = mstr.Trim(mstr.ToCharArray)
>  
> Given what I know about VB.Net (not very darned much) is this the best
way?
> I see where the string builder can do the substring part but it does 
> not have a trim method.
>  
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>  
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
> 
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.6.6/794 - Release Date: 5/8/2007 2:23
PM
 

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




More information about the dba-VB mailing list