문자열의 배열에 "zone_check_value"를 저장하려고합니다. 배열에 삽입하는 동안 다음 값이 반복되거나 중복되는 경우 문자열 배열을 검사합니다.For Each 루프를 사용하여 배열의 저장된 목록
예.
1st Example
1st loop = zone_check_value = ZD1/01/2014
2nd loop = zone_check_value = ZD1/01/2014
2nd Example
1st loop = zone_check_value = ZD1/01/2014
2nd loop = zone_check_value = ZD2/02/2014
3rd loop = zone_check_value = ZD1/01/2014
코드 :
For Each dt As DataTable In xls.Tables
Dim array_of_string as String() 'i want to put the value in here
For Each dr As DataRow In dt.Rows
Dim zone_destination As String = dr(2).ToString
Dim affected_date As String = dr(7).ToString
Dim zone_check_value = zone_destination + affected_date
''''''How can i store zone_check_value in a string array?
Next
Next
편집
어떻게 내가 내 루프를 선택하는 경우를 추가하면? array_of_string 값은 NULL이됩니다. array_of_string에서 현재 값의 값을 확인해야합니다.
예제 코드
For Each dt As DataTable In xls.Tables
Dim array_of_string as String() 'i want to put the value in here
select Case dt.tablename
case "Sheet1"
For Each dr As DataRow In dt.Rows
Dim zone_destination As String = dr(2).ToString
Dim affected_date As String = dr(7).ToString
Dim zone_check_value = zone_destination + affected_date
''''''How can i store zone_check_value in a string array?
Next
case "Sheet 2"
For Each dr As DataRow In dt.Rows
Dim check_value as Boolean = array_of_string.Contains(dr(0).ToString)
'but when i got in sheet 2 the array_of_string is null
Next
Next
이 질문에 vb.net 및 vba 태그가 추가되었습니다. 둘 중 하나를 선택하십시오. –
죄송합니다. @ Dan-o 이제 편집했습니다 – Denmark