Community articleSetting a Value in 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 a form is loaded into memory, a developer can set the values associated with any of the item or option nodes located in the form by calling SetLiteralByRefEx.
Change the values of hidden fields in the original form. These hidden fields are arguments for a compute in the SHOWAGE label that calculates the user's age. To do this, we will use three separate functions. Each function uses SetLiteralByRefEx to set one of the values.
   Sub SetBirthDay(BDay As Integer, TheForm As IFormNodeP)
 
      Dim Day As String
      
      ' Convert the birthday to a String
 
      Day = CStr(BDay)
 
      ' Call TheForm.SetLiteralByRefEx. The parameters are:
      '   1. vbNullString : reserved. Must be vbNullString.
      '   2. PAGE1.HIDDENDAY.value : the reference to the node.
      '   3. 0 : must be zero.
      '   4. vbNullString : sets the character set to ANSI.
      '   5. Nothing : no namespace node required.
      '   6. Day : the value to assign to the literal.
      ' An Exception will be thrown if there is a problem.
 
      TheForm.SetLiteralByRefEx vbNullString, "PAGE1.HIDDENDAY.value", _
         0, vbNullString, Nothing, Day
 
   End Sub
 
   ' Similar to SetBirthDay()
 
   Sub SetBirthMonth(BMonth As Integer, TheForm As IFormNodeP)
 
      Dim Month As String
 
      ' Convert the birth month to a String
      
      Month = CStr(BMonth)
 
      ' Set the birth month as a value in the form.
      TheForm.SetLiteralByRefEx vbNullString, "PAGE1.HIDDENMONTH.value", _
         0, vbNullString, Nothing, Month
 
   End Sub
 
   ' Similar to setBirthDay()
 
   Sub SetBirthYear(BYear As Integer, TheForm As IFormNodeP)
 
      Dim Year As String
 
      ' Convert the birth year to a String
 
      Year = CStr(BYear)
 
      ' Set the birth year as a value in the form.
 
      TheForm.SetLiteralByRefEx vbNullString, "PAGE1.HIDDENYEAR.value", _
         0, vbNullString, Nothing, Year
 
   End Sub