• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3959
  • Last Modified:

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

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.
0
LeeDerbyshire
Asked:
LeeDerbyshire
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
Try this:

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

End If

Bob
0
 
LeeDerbyshireAuthor Commented:
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.
0
 
Bob LearnedCommented:
Look at these values:

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

Bob
0
 
LeeDerbyshireAuthor Commented:
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?
0
 
LeeDerbyshireAuthor Commented:
Got it - I can use the upper bound of the array returned here:

http://support.microsoft.com/kb/312558

The points are yours - I have unlimited points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now