Request.Form("whatever").Count equivalent in VB.Net ?

Posted on 2007-07-26
Medium Priority
Last Modified: 2008-01-09
I expect this will be easy for the experts to answer, but it's not so easy for a beginner like me to work it out.  How can I duplicate this VBScript line:

  If Request.Form("whatever").Count = 1 Then

in VB.Net?  VB.Net doesn't like this, because Request.Form now seems to return a String (or could it be an array of strings), instead of a collection.
Question by:LeeDerbyshire
  • 3
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 19574658
Try this:

If Not Request.Form("name") Is Nothing Then

End If

LVL 31

Author Comment

ID: 19574725
Hi Bob, thanks for the reply.  I'd discovered the test for Nothing, but I need to know if exactly 1 form value with that particular name has been passed.  IsNothing will tell me if any values are passed or not, but I need to know the actual number, if possible.
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 19574881
Look at these values:

    For Each key As String In Request.Form.AllKeys
      Dim value As String = Request.Form(key)

LVL 31

Author Comment

ID: 19575194
Thanks, I can use that to show me what was input.  The problem is, though, I have a common form reading routine in an include file that checks form input from various sources (it checks for extended characters, and changes everything to UTF-8, rather than local 8-bit characters), so I never use Request.Form("name") throughout the application, I pass the name to my own routine.  One of the things it needs to know is how many instances of 'name' were returned (which is why I previously used .Count).  The form page could have had several controls with the same name on, in which case the values can easily be retrieved from the collection, but in VB.Net, you seem to get a single string with commas in.  But what if one of the inputs actually contained a comma?  Perhaps this is just one of the things I can no longer do?
LVL 31

Author Comment

ID: 19575395
Got it - I can use the upper bound of the array returned here:


The points are yours - I have unlimited points.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question