Community articleRetrieving A Value from a Form
Added by IBM contributorIBM on May 3, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



Once you have set up and initialized your application with the API and loaded a form into memory, your application is ready to start working with the form. The following code uses GetLiteralByRefEx to get a specific value from the form:
Retrieve the birth date from the form as three separate values: the birth day, birth month, and birth year. To do this, we will use three separate functions. Each function uses GetLiteralByRefEx to retrieve one of the values.
   Function GetBirthDay(TheForm) As Integer
 
      Dim BDay As String
 
      ' Call IFormNodeP.GetLiteralByRefEx to get the literal information for
      ' the PAGE1.BIRTHDAY.value node.  An exception will be thrown if
      ' there is a problem.
 
      BDay = TheForm.GetLiteralByRefEx(vbNullString, _
         "PAGE1.BIRTHDAY.value",  0, vbNullString, Nothing)
 
      ' If a literal value was returned, convert it into an integer value;
      ' otherwise, indicate that no value was entered into the field
      ' and throw an exception.
 
      If (Len(BDay) > 0) Then
         GetBirthDay = CInt(BDay)
      Else
         MsgBox "The birth day was not entered.", vbCritical
         Stop
      End If
    
   End Function
 
' Similar to GetBirthDay
 
   Function GetBirthMonth(TheForm) As Integer
 
      Dim BMonth As String
 
      BMonth = TheForm.GetLiteralByRefEx(vbNullString, _
         "PAGE1.BIRTHMONTH.value", 0, vbNullString, Nothing)
 
      If (Len(BMonth) > 0) Then
         GetBirthMonth = CInt(BMonth)
      Else
         MsgBox "The birth month was not entered.", vbCritical
         Stop
      End If
 
   End Function
 
' Similar to getBirthDay()
 
   Function GetBirthYear(TheForm) As Integer
 
      Dim BYear As String
 
      BYear = TheForm.GetLiteralByRefEx(vbNullString, _
         "PAGE1.BIRTHYEAR.value", 0, vbNullString, Nothing)
 
      If (Len(BYear) > 0) Then
         GetBirthYear = CInt(BYear)
      Else
         MsgBox "The birth year was not entered.", vbCritical
         Stop
      End If
 
   End Function