Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:07:29+00:00 2026-05-27T10:07:29+00:00

Sorry if this is a dumb question. I don’t ever have to write anything

  • 0

Sorry if this is a dumb question. I don’t ever have to write anything in VB.NET.

But I am passing variables named “name” to a function and sometimes it may be 1 name or 2 names, etc. I want to check in the function if its only 1 name don’t add a comma, if it’s 2 names add a comma. Is there a way to get how many “names” there are?

EDIT: Added my ode to make my question a little more clear. sorry for not doing it before.

My Code:

Public Function GenerateCSV(byval str as string, byval str1 as string, byval str2 as string, byval GrpName as string) 
  IF GroupName <> GrpName THEN
    GroupName = GrpName
    CSVString = ""
  END IF
  IF str = ""
    CSVString = ""
  ELSE
    CSVString = CSVString & str & ", " & str1 & ", " & str2 & ", " 
  END IF
  return CSVString
End function

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:07:29+00:00Added an answer on May 27, 2026 at 10:07 am

    Pass them as a List or array. With these, you can get the number of items and do whatever processing you need to do.

    Public Function DoSomething(names As IEnumerable(Of String)) As String
        'Include this if there is a possibility of an names containing nothing
        If names.Count = 0 Then
            Return ""
        End If
    
        Dim csvString As String = names(0)
    
        'First one is already added, loop through remaining
        For i As Integer = 1 To (names.Count - 1)
            csvString = csvString + ", " + names(i)
        Next
    
        Return csvString
    End Function
    

    You would preferably use IEnumerable which can take arrays or list among other things. You could use IList(Of String) or String() if you wanted though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this is a dumb question, but I have absolutely no idea how
Ok sorry this might seem like a dumb question but I cannot figure this
sorry this is probably a dumb question, but I want to make the background
Sorry if this is a dumb question but for the life of me I
This might be a dumb question. Sorry if it is. But Im working on
I'm sorry if this will sound like a dumb question but I just can't
I'm sorry if this is a dumb question. But if i set up devise,
Sorry if this is a dumb question, but it is possible to store, and
Sorry if this has been asked before or it's a really dumb question, but
Sorry for the dumb question, but... I'm moving from VB to C# and this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.