Phil J Fry
Phil J Fry

Reputation: 293

Using My.Settings

In VB.NET, can you store a opacity setting in My.Settings? How?

Me.Opacity = 1.0R '(1.0R is a Double)

What is the R / What does it do? And how can I store the 1.0R or 0.25R in My.Settings ? Or is there a better way to store the user’s setting?

Me.Opacity = My.Settings.Opacity Go to Settings and set Opacity as a Double that equals 0.5

Then my background image disappears / it is white, semi-transparent and missing labels, yet if I apply the same equals 1.0, it's fine (Go to Settings and set Opacity as a Double that equals 1.0)

Upvotes: 1

Views: 661

Answers (2)

Phil J Fry
Phil J Fry

Reputation: 293

By loading the settings onload

Private Sub ... .Load

    Me.Opacity = My.Settings.Opacity

End Sub

It is working fine. I have not isolated it down yet, but the main variable between it working and then not working was Windows 8. When I publish the app I will retest on 8 and verify.

Upvotes: 0

Ry-
Ry-

Reputation: 225291

Go into your project settings and pick the Settings tab; then, create a new User Setting called, for example, Opacity, and set its type to Double. You can now get and set My.Settings.Opacity; by default, user settings will also be saved for you when the application closes.

The R is just a type suffix meaning Double — it’s unnecessary, as 1.0 will be assumed to be a Double all the same. Don’t worry, no obscure types here :)

Upvotes: 2

Related Questions