InsertTag Example for VB.NET
'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "ListView1" of type "ListView" from ".NET Framework".
Private Sub TestInsertTag()
Dim nRet As Short
Dim ItemX As System.Windows.Forms.ListViewItem
Dim szItem As String
Dim nLen As Short
Dim x As Short
Dim szItemL As String
Dim szItemR As String
On Error GoTo INSERTTAGERROR
LEADDICOM1.EnableMethodErrors = False
nRet = LEADDICOM1.FindTag(131079)
If (nRet = 0) Then
MessageBox.Show("Already Exists!")
Exit Sub
End If
nRet = LEADDICOM1.InsertTag(131079, -1, "My Test Tag", LTDICLib.DicomVRCodeConstants.VR_OB, 1, 1, 1)
If (nRet <> 0) Then
MessageBox.Show("Error")
End If
LEADDICOM1.EnableMethodErrors = True
'add item to the ListView control
ItemX = New ListViewItem
ListView1.Items.Add(ItemX)
szItem = Hex(LEADDICOM1.CurrentTag.Code)
nLen = Len(szItem)
szItemR = szItem.Substring(szItem.Length - 4)
szItemL = ""
For x = nLen To 7
szItemL = szItemL & CStr(0)
Next
szItemL = szItemL & szItem.Substring(0, nLen - 4)
ItemX.Text = szItemL & ":" & szItemR
szItem = Hex(LEADDICOM1.CurrentTag.Mask)
nLen = Len(szItem)
szItemR = szItem.Substring(szItem.Length - 4)
szItemL = ""
For x = nLen To 7
szItemL = szItemL & CStr(0)
Next
szItemL = szItemL & szItem.Substring(0, nLen - 4)
ItemX.SubItems.Add(szItemL & ":" & szItemR)
ItemX.SubItems.Add(LEADDICOM1.CurrentTag.Name)
ItemX.SubItems.Add(CStr(LEADDICOM1.CurrentTag.VR))
ItemX.SubItems.Add(CStr(LEADDICOM1.CurrentTag.MinVM))
ItemX.SubItems.Add(CStr(LEADDICOM1.CurrentTag.MaxVM))
ItemX.SubItems.Add(CStr(LEADDICOM1.CurrentTag.DivideVM))
ItemX.Selected = True
ListView1.Refresh()
ListView1.Focus()
Exit
Sub
INSERTTAGERROR:
MessageBox.Show("Error")
End Sub