本文介绍了字符串问题 - 请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一点问题就是用一些,来连接一个字符串。这是我的代码: Dim mystring as string ="" for i = 1到3 mystring = mystring& "," &安培; Otherstring next i 我正在得到这样的结果 " a,b,c, 和数字我得到这个结果 ",1,2,3" 我怎样才能做到a,b,c和1,2,3 ? 谢谢。 T :-) 解决方案 也许是这样的: dim mystring as string ="" for i = 1 to 3 如果len(mystring)= 0那么 mystring = Cstr(i) else mystring = mystring& , &安培; CStr(i) 结束如果 下一个我 这将给你1,2,3 希望这会有所帮助.. Imran。 Tiraman: - ) < TI ***** @ netvision.net.il>在消息中写道 新闻:uT ************** @ TK2MSFTNGP10.phx.gbl ... hi, 我有一个小问题,用一些,来连接一个字符串。这是我的代码: Dim mystring as string ="" for i = 1 to 3 mystring = mystring& ; "," &安培; Otherstring 接下来我就得到这样的结果 a,b,c," 和得到这个结果的数字 ",1,2,3" 如何使它成为a,b,c和1,2,3 ? 谢谢。 T :-) 这里是'单程。请注意,该功能不做任何检查或修剪, 所以它会愉快地附加空字符串或字符串,只包含 空格。另请注意,如果你要做很多这些字符串 连接,你应该使用StringBuilder。 函数AppendCommaDelimitedValue(ByVal s作为String,ByVal appendValue As String)As String 如果s.Length = 0那么 s = appendValue Else s = s& "," &安培; appendValue 结束如果 返回s 结束功能 Tiraman: - ) < TI ***** @ netvision.net.il>在消息中写道 新闻:uT ************** @ TK2MSFTNGP10.phx.gbl ... hi, 我有一个小问题,用一些,来连接一个字符串。这是我的代码: Dim mystring as string ="" for i = 1 to 3 mystring = mystring& ; "," &安培; Otherstring 接下来我就得到这样的结果 a,b,c," 和得到这个结果的数字 ",1,2,3" 如何使它成为a,b,c和1,2,3 ? 谢谢。 T :-) *" Tiraman :-\)" < TI ***** @ netvision.net.il> scripsit:我有一个问题,就是用一些,来连接一个字符串。这是我的代码: Dim mystring as string ="" for i = 1 to 3 mystring = mystring& ; "," &安培; Otherstring 接下来我就得到这样的结果 a,b,c," 和得到这个结果的数字 ",1,2,3" 如何使它成为a,b,c和1,2,3 ? \\\ Dim MyString As String = OtherString for i = 2 to 3 MyString& ="," MyString& = OtherString Next i / // - MS Herfried K. Wagner MVP< URL:http://dotnet.mvps。 org /> VB< URL:http://dotnet.mvps.org/dotnet/faqs/> hi, i have a little problem to concat a string with some "," sign. this is my code: Dim mystring as string = ""for i=1 to 3mystring = mystring & "," & otherstringnext i and i m getting the result like this "a,b,c," and with numbers i m getting this result ",1,2,3" how can i make it "a,b,c" and "1,2,3" ? Thanks.T :-) 解决方案 maybe something like this: dim mystring as string = ""for i=1 to 3if len(mystring) = 0 thenmystring = Cstr(i)elsemystring = mystring & ", " & CStr(i)end ifnext i this will give you 1,2,3 hope this helps..Imran. "Tiraman :-)" <ti*****@netvision.net.il> wrote in messagenews:uT**************@TK2MSFTNGP10.phx.gbl... hi, i have a little problem to concat a string with some "," sign. this is my code: Dim mystring as string = "" for i=1 to 3 mystring = mystring & "," & otherstring next i and i m getting the result like this "a,b,c," and with numbers i m getting this result ",1,2,3" how can i make it "a,b,c" and "1,2,3" ? Thanks. T :-) Here''s one way. Note that the function doesn''t do any checking or trimming,so it will happily append empty strings or strings containing nothing butwhite space. Also note that if you''re going to do very many of these stringconcatenations, you should use a StringBuilder instead. Function AppendCommaDelimitedValue(ByVal s As String, ByVal appendValueAs String) As StringIf s.Length = 0 Thens = appendValueElses = s & "," & appendValueEnd IfReturn sEnd Function"Tiraman :-)" <ti*****@netvision.net.il> wrote in messagenews:uT**************@TK2MSFTNGP10.phx.gbl... hi, i have a little problem to concat a string with some "," sign. this is my code: Dim mystring as string = "" for i=1 to 3 mystring = mystring & "," & otherstring next i and i m getting the result like this "a,b,c," and with numbers i m getting this result ",1,2,3" how can i make it "a,b,c" and "1,2,3" ? Thanks. T :-) * "Tiraman :-\)" <ti*****@netvision.net.il> scripsit: i have a little problem to concat a string with some "," sign. this is my code: Dim mystring as string = "" for i=1 to 3 mystring = mystring & "," & otherstring next i and i m getting the result like this "a,b,c," and with numbers i m getting this result ",1,2,3" how can i make it "a,b,c" and "1,2,3" ? \\\Dim MyString As String = OtherStringFor i = 2 to 3MyString &= ","MyString &= OtherStringNext i/// --M S Herfried K. WagnerM V P <URL:http://dotnet.mvps.org/>V B <URL:http://dotnet.mvps.org/dotnet/faqs/> 这篇关于字符串问题 - 请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 17:03