Hi There Guys,

I'm trying to get my head around this issue, on a few of my functions i get a warning " 'functionDealWithHiddenFields' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."

Example function:

vb.net Code:
  1. Function functionDealWithHiddenFields(ByVal HTML As String, ByVal numHiddenFields As Integer, ByVal X As Integer)
  2.  
  3.         Try
  4.  
  5.             'For i As Integer = 0 To numHiddenFields
  6.             '// The html source
  7.             Dim sText = HTML
  8.  
  9.             '// The string we are searching for
  10.             Dim sPattern As String = "(?<=<input type=""hidden"" class="").*?(?="".*?')"
  11.  
  12.             '// This is the regular expression
  13.             Dim regex As New Regex(sPattern, RegexOptions.IgnoreCase Or RegexOptions.Singleline)
  14.  
  15.             '// The matches that we return are put in the matchcollection
  16.             Dim regexMatches As MatchCollection = regex.Matches(sText)
  17.  
  18.             '// Return
  19.             'Return regexMatches(0).ToString
  20.             'MessageBox.Show("Hidden Field " & X & ": " & regexMatches(X).ToString)
  21.  
  22.             Return regexMatches(X).ToString
  23.  
  24.         Catch ex As Exception
  25.  
  26.             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  27.  
  28.         End Try
  29.  
  30.     End Function

The functions still work correctly (as far as i can tell) what would i need to do to the above function to remedy that warning?

thanks for any info guys

Graham