2011-03-11 8 views
1

어떻게 문자열을 배열로 변환 할 수 있습니까?문자열을 vb.net의 배열로 변환

값은 문자열로 전달됩니다

Dim strInput as string 
strInput = "Tom, John, Jason, Mike" 

내 오류 메시지는 다음과 같습니다 Value of type 'String' cannot be converted to 'System.Array'

답변

12

사용 System.String.Split :

Dim source As String = "Tom, John, Jason, Mike" 
Dim stringSeparators() As String = {","} 
Dim result() As String 
result = source.Split(stringSeparators, _ 
         StringSplitOptions.RemoveEmptyEntries) 

또는 Microsoft.VisualBasic.Strings.Split:

Dim source As String = "Tom, John, Jason, Mike" 
Dim result() As String = Split(source, ",") 
3

당신은 분할을 사용할 수 있습니다(). here을 참조하십시오.

0

strInput.Split (새 문자열() { ","}, StringSplitOptions.RemoveEmptyEntries)

를 사용
관련 문제