SendNSetRequest Example for VB.NET

'LEADDICOMNet1 is a predefined LEADDicomNet object
'LEADDICOM1 is a DICOM Dataset defined outside this method
Private Sub TestSendNSetRequest ( )
   Const UID_SC_IMAGE_STORAGE As String = "1.2.840.10008.5.1.4.1.1.7"
   ' Secondary Capture Image Storage
   Dim nRet As Short
   Dim szClassUID As String
   Dim szInstance As String
   Dim hPDU As Integer
   Dim nID As Short
   Dim szNewID As String
   'this sample allows you to change the patient id of an SOP Instance
   'send an N-GET-REQUEST to the server
   szClassUID = InputBox("What class do you wish to set?", "Set Request", UID_SC_IMAGE_STORAGE)
   If (Len(szClassUID) < 1) Then Exit Sub
   szInstance = InputBox("What instance do you wish to set?", "Set Request", "1.1.1.1")
   If (Len(szInstance) < 1) Then Exit Sub
   szNewID = InputBox("Enter New Patient ID?", "Set Request", "123-45-6789")
   If (Len(szNewID) < 1) Then Exit Sub
   'create the data set that encodes the changed element(s)
   LEADDICOM1.InitDS(LTDICLib.DicomClassConstants.DICOM_CLASS_UNKNOWN, 0)
   LEADDICOM1.ResetDS()
   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID)
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID, LEADDICOM1.CurrentTag.VR, False, 0)
   LEADDICOM1.StringValueCount = 1
   LEADDICOM1.StringValues(0) = szNewID
   LEADDICOM1.SetStringValue(1)
   hPDU = LEADDICOMNet1.GetAssociate(LEADDICOMNet1.hNet)
   'now, send a request
   nID = LEADDICOMNet1.FindPresentationAbstract(hPDU, szClassUID)
   If (nID = 0) Then
      nRet = LEADDICOM1.FindUID(szClassUID)
      If (nRet = 0) Then
         MessageBox.Show("Abstract Syntax, " & LEADDICOM1.CurrentUID.Name & ", Not Supported by Association!")
      Else
         MessageBox.Show("Abstract Syntax, " & szClassUID & ", Not Supported by Association!")
      End If
      Exit Sub
   End If
   LEADDICOMNet1.SendNSetRequest(LEADDICOMNet1.hNet, nID, 1, szClassUID, szInstance, LEADDICOM1.hDicomDS)
End Sub