# Visual Basic > Visual Basic .NET > VS 2022 ToolTip declaration expected

## hcccsw

I'm testing a ToolTip and I get squiggly lines and remark "declaration expected" although I just declared the ToolTip



```
Public Class Form1
    Dim buttonToolTip As New ToolTip()
    buttonToolTip.ToolTipTitle = "Button Tooltip"
    buttonToolTip.UseFading = True
    buttonToolTip.UseAnimation = True
    buttonToolTip.IsBalloon = True
    buttonToolTip.ShowAlways = True
    buttonToolTip.AutoPopDelay = 5000
    buttonToolTip.InitialDelay = 1000
    buttonToolTip.ReshowDelay = 500
    buttonToolTip.IsBalloon = True
    buttonToolTip.SetToolTip(Button1, "Click me to execute.")
End Class
```

----------


## dbasnett

All of the buttonToolTip method / property statements need to be in a method, maybe even the declaration depending on what you are trying to do.

----------


## techgnome

Yes, but you declared it in the form root ... it needs to be inside a sub. like in the form load even or something.

-tg

----------


## jmcilhinney

There's really no good reason to be creating a ToolTip in code to begin with. Add one to your form in the designer and set it's properties there, just as you would for a control. You also shouldn't need to call SetToolTip. Once the ToolTip has been added to the form, each control will gain new items in the Properties window relating to that and you can just set the text for each control there.

If you were going to do it in code though, you should specify an access modifier for the field and use object initialiser syntax to set the properties, e.g.

vb.net Code:
Private buttonToolTip As New ToolTip With {.ToolTipTitle = "Button Tooltip",
                                           .UseFading = True,
                                           .UseAnimation = True,
                                           .IsBalloon = True,
                                           .ShowAlways = True,
                                           .AutoPopDelay = 5000,
                                           .InitialDelay = 1000,
                                           .ReshowDelay = 500}
You would then call the SetToolTip method in the Load event handler of the form.

----------

