修剪字符不起作用 [英] Trimming characters not working

查看:68
本文介绍了修剪字符不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我从字符串开头修剪字符时遇到问题.这是我的代码


Hi,
I have a problem with trimming character from the start of a string. This is the code I have


For Each i As String In lstSearch.Items

                Dim MyString As String = i

                Dim MyChar() As Char = {"\", "\", "1", "9", "2", ".", "1", "6", "8", ".", "6",, "\", "m", "y", "s", "h", "a", "r", "e", "_", "P", "r", "o", "d", "u", "c", "t", "i", "o", "n", "$", "\"}
                ' msgBox(MyChar)
                Dim newstring1 As String = MyString.TrimStart(MyChar)
                lstResults.Items.Add(newstring1)
            Next



它是在目录中搜索文件的部分.该文件的名称如下所示

AG000000_Share_Local_9_Reference.zip

但是,当我在其上使用修剪时,它总是在文件名的开头删除A.变成

G000000_Share_Local_9_Reference.zip

我不知道为什么当只应修剪文件名时为什么会不断修剪文件名的第一个字符

\\ 192.168.6 \ myshare_production $ \

但总是修剪

\\ 192.168.6 \ myshare_production $ \ A

如果有人可以帮忙,我将不胜感激

谢谢
J



Its part of searchng a directory for a file. The file is named something like this

AG000000_Share_Local_9_Reference.zip

But when I use the trim on it it always removes the A at the start of the file name. So it becomes

G000000_Share_Local_9_Reference.zip

I can''t figure out why it keeps trimming the first character of the file name when it should only be trimming

\\192.168.6\myshare_production$\

but always trims

\\192.168.6\myshare_production$\A

I''d be greatful if someone could help

Thanks
J

推荐答案

", \ "} ' msgBox(MyChar) Dim newstring1 As String = MyString.TrimStart (我的Char) lstResults.Items.Add(newstring1) 下一步
", "\"} ' msgBox(MyChar) Dim newstring1 As String = MyString.TrimStart(MyChar) lstResults.Items.Add(newstring1) Next



它是在目录中搜索文件的部分.该文件的名称如下所示

AG000000_Share_Local_9_Reference.zip

但是,当我在其上使用修剪时,它总是在文件名的开头删除A.变成

G000000_Share_Local_9_Reference.zip

我不知道为什么当只应修剪文件名时为什么会不断修剪文件名的第一个字符

\\ 192.168.6 \ myshare_production



Its part of searchng a directory for a file. The file is named something like this

AG000000_Share_Local_9_Reference.zip

But when I use the trim on it it always removes the A at the start of the file name. So it becomes

G000000_Share_Local_9_Reference.zip

I can''t figure out why it keeps trimming the first character of the file name when it should only be trimming

\\192.168.6\myshare_production


\

但总是修剪

\\ 192.168.6 \ myshare_production
\

but always trims

\\192.168.6\myshare_production


\ A

如果有人可以帮忙,我将不胜感激

谢谢
J
\A

I''d be greatful if someone could help

Thanks
J


这篇关于修剪字符不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆