GetCharValue Example for Visual Basic
Private Sub TestProc2()
Dim lCount As Long
Dim x As Long
Dim nRet As Integer
Dim nLen As Integer
Dim szChars As String
Dim szChar As String
Dim byteVal As Byte
LEADDICOM1.EnableMethodErrors = False
'move to the root element
LEADDICOM1.MoveFirstElement False
LEADDICOM1.MoveRootElement
'insert a new element for the Char Values
LEADDICOM1.InsertElement False, TAG_PIXEL_DATA, VR_OB, False, 0
Text1.Visible = True
Text1.Text = ""
'insert some char values into the element
szChars = "This is a Test 1234!"
nLen = Len(szChars)
LEADDICOM1.CharValueCount = nLen
For x = 0 To nLen - 1
szChar = Mid$(szChars, x + 1, 1)
byteVal = CByte(Asc(szChar))
LEADDICOM1.CharValues(x) = CInt(byteVal)
Next
'set the chars
nRet = LEADDICOM1.SetCharValue(nLen)
If (nRet <> 0) Then
MsgBox "Error"
Exit Sub
End If
LEADDICOM1.CharValueCount = 0 'free the values
'get the value count
lCount = LEADDICOM1.GetValueCount
MsgBox "There are " & CStr(lCount) & " values!"
'get the values
nRet = LEADDICOM1.GetCharValue(0, lCount)
If (nRet = 0) Then
For x = 0 To LEADDICOM1.CharValueCount - 1
'display each value separated by a '.'
Text1.Text = Text1.Text & "." & Chr(LEADDICOM1.CharValues (x))
Next
End If
LEADDICOM1.EnableMethodErrors = True
msgbox "wait"
End Sub