GetUserInfoCount Example for VB.NET

'LEADDICOMNet1 is a predefined LEADDicomNet object
Private Sub TestGetUserInfoCount ()
   Dim x As Integer
   Dim y As Integer
   Dim nType As Short
   Dim nLen As Short
   Dim pData As Object
   Dim out As String
   Dim test As Object

   'create the Associate Class as Request
   LEADDICOMNet1.CreateAssociate(True)
   'set the Associate to the default
   LEADDICOMNet1.DefaultAssociate(LEADDICOMNet1.hPDU)

   'get current user info types, lengths, and data then display them
   out = ""
   If (LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) > 0) Then
      For x = 0 To LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) - 1
         nType = LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU, x)
         out = out & "Type: " & CStr(nType)
         nLen = LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU, x)
         out = out & " Length: " & CStr(nLen)
         pData = LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU, x)
         out = out & " Data: "
         For y = 0 To nLen - 1
            out = out & Chr(pData(y))
         Next
         out = out & Chr(13)
      Next
   Else
      out = "None"
   End If
   MessageBox.Show(out)

   'add a user info item item
   out = ""
   test = "just a test"
   nLen = Len(test)
   LEADDICOMNet1.AddUserInfo(LEADDICOMNet1.hPDU, 99, test, Len(test))
   out = ""
   If (LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) > 0) Then
      For x = 0 To LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) - 1
         nType = LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU, x)
         out = out & "Type: " & CStr(nType)
         nLen = LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU, x)
         out = out & " Length: " & CStr(nLen)
         pData = LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU, x)
         out = out & " Data: "
         For y = 0 To nLen - 1
            out = out & Chr(pData(y))
         Next
         out = out & Chr(13)
      Next
   Else
      out = "None"
   End If
   MessageBox.Show(out)

   'for each user info item, change the data
   test = "a second test"
   For x = 0 To LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) - 1
      nType = LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU, x)
      LEADDICOMNet1.SetUserInfo(LEADDICOMNet1.hPDU, x, nType, test, Len(test))
   Next
   out = ""
   If (LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) > 0) Then
      For x = 0 To LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) - 1
         nType = LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU, x)
         out = out & "Type: " & CStr(nType)
         nLen = LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU, x)
         out = out & " Length: " & CStr(nLen)
         pData = LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU, x)
         out = out & " Data: "
         For y = 0 To nLen - 1
            out = out & Chr(pData(y))
         Next
         out = out & Chr(13)
      Next
   Else
      out = "None"
   End If
   MessageBox.Show(out)

   'delete the one we added
   LEADDICOMNet1.DeleteUserInfo(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU) - 1)
   LEADDICOMNet1.FreeAssociate(LEADDICOMNet1.hPDU)
End Sub