compugeek Posted September 20, 2003 Posted September 20, 2003 How do you change a form's opacity during run-time? Quote
*Experts* mutant Posted September 20, 2003 *Experts* Posted September 20, 2003 'for example 12% opacity Me.Opacity = 0.12 'or 67% opacity Me.Opacity = 0.67 Opacity accepts a Double value and a value between 0 and 1. Quote
compugeek Posted September 21, 2003 Author Posted September 21, 2003 Hm, no... I am using a TrackBar control, and at whatever position it is at, it will make the transparency. That doesn't seem to work, here's my code: Dim opace As Integer Dim Frm1 As New Form1() opace = tbOpacity.Value If opace = 1 Then Frm1.Opacity = 0.9 End If If opace = 2 Then Frm1.Opacity = 0.8 End If If opace = 3 Then Frm1.Opacity = 0.7 End If If opace = 4 Then Frm1.Opacity = 0.6 End If If opace = 5 Then Frm1.Opacity = 0.5 End If I dunno why this won't work. Quote
aewarnick Posted September 21, 2003 Posted September 21, 2003 (edited) Fist of all you are using your if control statements wrong. You code makes the program check each and every one even if it finds a match. In some cases you want that but not yours. Use "else if" after your first if. Edited September 21, 2003 by aewarnick Quote C#
*Experts* Volte Posted September 21, 2003 *Experts* Posted September 21, 2003 Why not just use (10 - opace) / 10? Also, you can't just create a new instance of the form as you are doing and change it. You need to modify the current instance of the form using the Me keyword. Try this (in the TrackBar change event):Me.Opacity = (10 - opace) / 10 Quote
compugeek Posted September 21, 2003 Author Posted September 21, 2003 Hey, thanks Volteface - and aewarnick for helping as well. It worked! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.