I’ve got a hierarchical listbox which is filled with a method that puts custom classes in the rowtag (when the folder is added) but which also adds a row to “subtotal” some data represented by the previous folder. I’ve added a string “subtotals” for the rowtag in this row, but was running into problems with the celltextpaint method.
I’d like this row to be a smaller sized font and italic. But I get TypeMismatchException when I try this:
if me.RowTag(row) = "subtoals" Then
g.TextSize = 10
g.Italic = True
Else
End if
I thought maybe this is where Try … Catch comes in, but having never used this before, the solution is eluding me. This next code (and a lot of variantions) is not working.
Try
Dim s As String
s = me.RowTag(row)
Catch e As TypeMismatchException
Return True
Dim s As String
s = me.RowTag(row)
if s = "subtotals" Then
g.TextSize = 10
g.Italic = True
Else
End if
End Try
So, I tried this and it works, but I wonder if this is the “proper and/or elegant” way to do this:
Dim v as Variant
v = me.RowTag(row)
if v.Type = 8 Then '8 is the value for "stringvalue"
if v = "subtotals" Then
g.TextSize = 10
g.Italic = True
End if
Else
End if
It just seems a bit convoluted, so I wonder if there is a better way? But maybe it’s fine to find the variant type and say if it’s “9” (object) then run IsA?
Like
[code]Select Case v.type
Case 9 ’ deal with objects
Case 8 ’ deal with strings
Else
End Select
[/code]
Happy to hear any ideas.