GetTimeValue 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 TestGetTimeValue()
   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 Time Value
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_TIME, LTDICLib.DicomVRCodeConstants.VR_TM, False, 0)

   'insert an Time value into the element
   LEADDICOM1.TimeValueCount = 1
   LEADDICOM1.TimeValues(0).Hours = 12
   LEADDICOM1.TimeValues(0).Minutes = 25
   LEADDICOM1.TimeValues(0).Seconds = 33
   LEADDICOM1.TimeValues(0).Fractions = 50

   'set the time
   nRet = LEADDICOM1.SetTimeValue(1)

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

   LEADDICOM1.TimeValueCount = 0 'free the value

   Text1.Visible = True
   Text1.Text = ""

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

   'get the value
   nRet = LEADDICOM1.GetTimeValue(0, lCount)
   'display the value
   Text1.Text = "Hours: " & CStr(LEADDICOM1.TimeValues(0).Hours) & " Minutes: " & CStr(LEADDICOM1.TimeValues(0).Minutes & " Seconds: " & CStr(LEADDICOM1.TimeValues(0).Seconds) & " Fractions: " & CStr(LEADDICOM1.TimeValues(0).Fractions))
   LEADDICOM1.EnableMethodErrors = True
   MessageBox.Show("wait")

End Sub