GetStringValue Example for VB.NET

'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "Text5" of type "TextBox" from ".NET Framework".
Private Sub TestGetStringValue()
   Dim lCount As Integer
   Dim x 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 String Values
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants1.TAG_IMAGE_TYPE, LTDICLib.DicomVRCodeConstants.VR_CS, False, 0)

   'insert some string values into the element
   LEADDICOM1.StringValueCount = 5
   For x = 0 To 5 - 1
      LEADDICOM1.StringValues(x) = "String #" & CStr(x + 1)
   Next
   'set the strings
   nRet = LEADDICOM1.SetStringValue(5)

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

   LEADDICOM1.StringValueCount = 0 'free the values

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

   'get the values
   nRet = LEADDICOM1.GetStringValue(0, lCount)
   If (nRet = 0) Then
      For x = 0 To LEADDICOM1.StringValueCount - 1
         'display each value separated on a separate line
         Text5.Text = Text5.Text & Chr(13) & Chr(10) & CStr(LEADDICOM1.StringValues(x))
      Next
   End If
   LEADDICOM1.EnableMethodErrors = True
   MessageBox.Show("wait")

End Sub