GetTransferCount Example for VB.NET

'LEADDICOMNet1 is a predefined LEADDicomNet object
Private Sub TestGetTransferCount ( )
   Const UID_IMPLICIT_VR_LITTLE_ENDIAN As String = "1.2.840.10008.1.2"
   ' Implicit VR Little Endian
   Const UID_EXPLICIT_VR_BIG_ENDIAN As String = "1.2.840.10008.1.2.2"
   ' Explicit VR Big Endian
   Dim x As Integer
   Dim out As String
   Dim result As String

   'create the Associate Class as Request
   LEADDICOMNet1.CreateAssociate(True)

   'set the Associate to the default
   LEADDICOMNet1.DefaultAssociate(LEADDICOMNet1.hPDU)

   'display each Transfer Syntax for the first Presentation Context
   out = ""
   For x = 0 To LEADDICOMNet1.GetTransferCount(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0)) - 1
      result = LEADDICOMNet1.GetTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), x)
      out = out & result
      out = out & Chr(13)
   Next
   MessageBox.Show(out)


   'add a transfer syntax
   LEADDICOMNet1.AddTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), UID_IMPLICIT_VR_LITTLE_ENDIAN)

   'display each Transfer Syntax for the first Presentation Context
   out = ""
   For x = 0 To LEADDICOMNet1.GetTransferCount (LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0)) - 1
      result = LEADDICOMNet1.GetTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), x)
      out = out & result
      out = out & Chr(13)
   Next
   MessageBox.Show(out)


   'change them
   For x = 0 To LEADDICOMNet1.GetTransferCount(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0)) - 1
      LEADDICOMNet1.SetTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), x, UID_EXPLICIT_VR_BIG_ENDIAN)
   Next

   'display each Transfer Syntax for the first Presentation Context
   out = ""
   For x = 0 To LEADDICOMNet1.GetTransferCount(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0)) - 1
      result = LEADDICOMNet1.GetTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), x)
      out = out & result
      out = out & Chr(13)
   Next
   MessageBox.Show(out)


   'delete the last one
   LEADDICOMNet1.DeleteTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), LEADDICOMNet1.GetTransferCount(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0)) - 1)


   'display each Transfer Syntax for the first Presentation Context
   out = ""
   For x = 0 To LEADDICOMNet1.GetTransferCount(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0)) - 1
      result = LEADDICOMNet1.GetTransferSyntax(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetPresentationID(LEADDICOMNet1.hPDU, 0), x)
      out = out & result
      out = out & Chr(13)
   Next
   MessageBox.Show(out)

   LEADDICOMNet1.FreeAssociate(LEADDICOMNet1.hPDU)
End Sub