operator & not supported

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I code the following
dim s as string = vbcr & vbc
Catch ex As Exceptio
MsgBox(ex.Message & s & ex.HelpLink & s & ex.StackTrace

The message prints out fine, except the HelpLink doesn't appear.

But when I include the following in the msgbox
MsgBox(ex.Message & s & ex.HelpLink & s & ex.StackTrace & s & ex.Source & s & ex.TargetSite
I get the message

Operator & is not defined for types 'string' and 'system.reflection.methodbase

Could somebody explain this to me.

Also, is there a property or method that would give me the 'name' of the exception

polynomial5d
 
The ex.TargetSite is not a string, it is a System.Reflection.MethodBase object, and as such cannot be added to your message box output. Depening on what you want to achieve in your message box output, try looking at the methods of the MethodBase (probably Name and DeclaringType) to see what information can be displayed as a string

Also, you can get the 'name' of an Exception using ex.GetType.ToString - assuming by name you mean something like System.ArgumentException

HT

RS
 
Back
Top