CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Visual studio 2008 - Loop in Array

    Hi to all!!!!

    I have a parameter field which is of the form "20-100-105"
    I use the commands
    Dim DimArr() As String
    DimArr = Dim_Len.Split("-")
    I want to create a loop to find out how many fields in my array is not empty.
    "20-100" = 2
    "20-100-105" = 3
    "20-100-105-160" = 4

    Can anyone help me!!!!!!

    Thanks and regards.

  2. #2
    Join Date
    Dec 2012
    Posts
    2

    Re: Visual studio 2008 - Loop in Array

    Finally is too silly question.....
    Dim i As Integer = DimArr.Length

  3. #3
    Join Date
    Mar 2004
    Posts
    41

    Re: Visual studio 2008 - Loop in Array

    Hey,

    You should use something along the lines of:

    Code:
    dim number_of_not_empty_fields as integer = 0
    Dim DimArr() As String
    
    DimArr = Dim_Len.Split("-")
    
    For each Fieldcount in Dimarr
    
    if Dimarr(Fieldcount).length > 0 then
    number_of_not_empty_fields += 1
    end if
    Next
    I haven't tested it but should be close

    -Robbo
    Hope it helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured