如何在vb.net中修剪字符串 [英] How to trim a string in vb.net
本文介绍了如何在vb.net中修剪字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在VB.NET中有问题
我有字符串数组.该数组包含左右两侧都有空格的字符串.我如何删除空格.我将字符串放入Datarow.
我这样做,但要修剪右侧.我也要修剪左侧.
请帮帮我.
Hi everyone,
I have an issue in VB.NET
I have string array.That array contains strings having spaces bothsides(left and right).How do i remove spaces.I am putting string in Datarow.
I am doing like this,but its trimming right side.I want to trim left side also.
Please help me out.
Dim EachLineData() As String = Split(sLine, sCharSep)
dataRw(iCol) = EachLineData(iCol).ToString.PadRight(aColLen(iCol) + 1).Remove(aColLen(iCol)).TrimEnd
推荐答案
仅使用"Trim"从两侧去除多余的空间,"TrimEnd"将仅去除右侧的多余空间
例如.
use only ''Trim'' to remove extra spaces from both side, ''TrimEnd'' will remove only right-side extra spacing
eg.
dim str as String = " aaa ";
str = str.Trim();
祝您编码愉快!
:)
Happy Coding!
:)
http://msdn.microsoft.com /en-us/library/d4tt83f9.aspx#Y0 [ ^ ]
修剪字符串中的后4个字符 [
http://msdn.microsoft.com/en-us/library/d4tt83f9.aspx#Y0[^]
Trim last 4 characters from string[^]
检查这一次
Check this once
YourString.Left(YourString.Length-4)
这篇关于如何在vb.net中修剪字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文