ReadTagMemory example for Visual Basic

Dim RasterIO As New LEADRasterIO

Private Sub ReadTagMemory_Click()
   Dim RasterVar As New LEADRasterVariant
   Dim nRet As Integer
   Dim hMem As Long
   Dim iSize As Long

   RasterVar.Type = VALUE_STRING
   RasterVar.StringValue = "My text string"

   RasterIO.SetTag 32768, TAG_ASCII, 0, RasterVar
   nRet = RasterIO.SaveMemory(LEADRasterView1.Raster, hMem, FILE_TIF, LEADRasterView1.Raster.BitmapBits, QFACTOR_LEAD_0, 0, iSize)
   nRet = RasterIO.ReadTagMemory(hMem, 1, 32768, iSize)

   Call GetAndDisplayTag(0)
End Sub

Private Sub GetAndDisplayTag(lTag As Long)
   Dim myVar As Variant
   Dim RasterVar As New LEADRasterVariant
   Dim Msg$
   Dim i As Long
   Dim count As Long

   Set RasterVar = RasterIO.GetTagData(lTag)
   count = RasterIO.GetTagCount(lTag)

   Msg$ = "Type = " + CStr(RasterIO.GetTagType(lTag))
   Msg$ = Msg$ + Chr$(10) + Chr$(13) + "count = " + CStr(count)
   If RasterIO.GetTagType(lTag) = TAG_ASCII Then
      Msg$ = Msg$ + Chr$(10) + Chr$(13) + "Data = " + RasterVar.StringValue
   ElseIf RasterIO.GetTagType(lTag) = TAG_RATIONAL Or _
      RasterIO.GetTagType(lTag) = TAG_SRATIONAL Then '
      For i = 0 To count - 1
         Msg$ = Msg$ + Chr$(10) + Chr$(13) + "Data(" + CStr(i) + ") = " + _
         CStr(RasterVar.ShortItemValue(i * 2)) + "/" + CStr(RasterVar.ShortItemValue(i * 2 + 1))
      Next i
   Else
      For i = 0 To count - 1
         Msg$ = Msg$ + Chr$(10) + Chr$(13) + "Data(" + CStr(i) + ") = " + _
         CStr(RasterVar.ShortItemValue(i))
      Next
   End If
   MsgBox Msg$
End Sub