Retrieving posted AcroFrom field value

Hello,

I have written VB.Net code that can successfully handle the posting of
a fillable PDF form (AcroForm). Basically, I created the form in
Adobe Acrobat Pro 9.0 and it contains a submit button which posts the
PDF form in FDF format to an apsx page on my server. In the Acrobat
settings I am sending all of the form fields in the post.

The code behind of my aspx page (the aspx.vb file) is now displaying
the name of the one and only form field on my sample PDF form (a
single text box). Also I am displaying a byte count of the FDF file
that I captured as a binary stream.

This chunk of the code below is where I use the FDFFieldIterator to
loop through the form fields and I write out the name and partial name
of the form field, as you can see. They both write out the same
name though, so I'm not sure what a "partial name" is, but I'm not
worried about that now. So writing out the field NAME works (if I
comment out the GetValue line). The line that is attempting to
write out the VALUE (text that was entered in the text box of the
form) is throwing an error, and I can't determine why.

It appears that field.GetValue() is not working. The error I am
getting is "Object reference not set to an instance of an object"

Any ideas how I can extract the value of the text box from the posted
AcroForm?

Thanks,

Charlie
************************************

While itr.HasNext()
            field = itr.Current

            str.Append("Field name: " & field.GetName & "<br />")
            str.Append("Field partial name: " & field.GetPartialName &
"<br />")
            str.Append("Field value: " & field.GetValue.ToString &
"<br />")

            itr.Next()
End While

field.GetValue() returns pdftron.SDF.Obj which is a low-level PDF
object representing the value of the field (it could be also null).

If you need a value in string represenation use
field.GetValueAsString().

Q: It seems that there is no GetValueAsString() utility method for the
FDFField object so I need to use GetValue(). I am not sure how that
would give me the value (what text is typed into the
text box) for a text box field. I am looking to retrieve the text in
the text box which I believe is its value.
--------------------
A: When you call field.GetValue() it returns a pdftron.SDF.Obj or
null.
The value (i.e. Obj) could be a string, a number, a name, or an array.
Depending on the object type you can call corresponding methods to
obtain the atomic values. For example:

string val;
Obj o = field.GetValue();
If (o != null) {
  if (o.IsString()) val = o.GetAsPDFText ();
  if (o.IsName()) val = o.GetName();
  else if (o.IsNumber()) val = o.GetNumber().ToString();
  // …
}

Please note that IsName()/IsString/IsNumber() are being called on Obj
and not on Field or FDFField.