GetAgeValue Example for VB.NET

'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "Text1" of type "TextBox" from ".NET Framework".
Private Sub TestGetAgeValue()
   Dim lCount As Integer
   Dim nRet As Short

   LEADDICOM1.EnableMethodErrors = False

   'move to the root element
   LEADDICOM1.MoveFirstElement(False)
   LEADDICOM1.MoveRootElement()

   'insert a new element for the Age Value
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_AGE, LTDICLib.DicomVRCodeConstants.VR_AS, False, 0)

   'insert an Age value into the element
   LEADDICOM1.AgeValueCount = 1
   LEADDICOM1.AgeValues(0).Number = 21
   LEADDICOM1.AgeValues(0).Reference = CShort(Asc("Y"))

   'set the age
   nRet = LEADDICOM1.SetAgeValue(1)

   If (nRet <> 0) Then
      MessageBox.Show("Error")
      Exit Sub
   End If

   LEADDICOM1.AgeValueCount = 0 'free the value

   'get the value count
   lCount = LEADDICOM1.GetValueCount
   MessageBox.Show("There are " & CStr(lCount) & " values!")

   'get the value
   nRet = LEADDICOM1.GetAgeValue(0, lCount)
   'display the value
   Text1.Text = "Number: " & CStr(LEADDICOM1.AgeValues (0).Number) & "Ref: " & Chr(LEADDICOM1.AgeValues(0).Reference)
   LEADDICOM1.EnableMethodErrors = True MessageBox.Show("wait")
End Sub