Tuesday, January 28, 2014

Fade In Loading Form Visual Basic 2010 / 2012 - Simple Codes

Hi,

I want to make "auto fade in show form" in vb, here codes;


Insert to 1 timer, 1 label, 1 Trackbar in form1


Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Start()
        Me.Opacity = 0.01                                                               'Minimum Opacity

        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))                                                                         'Label1 Font Size = 24

        Label1.Dock = DockStyle.Fill                                                    'Location for Label1
        TrackBar1.Dock = DockStyle.Bottom                                               'Location for Trackbar

    End Sub


    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If Me.Opacity < 1 Then Me.Opacity = Me.Opacity + 0.01 Else Timer1.Stop() 'Adjust Form Opacity
        TrackBar1.Value = 100 * Me.Opacity                                          'Trackbar1 Value = Form Opacity Value
        Label1.Text = "% " & (Me.Opacity * 100)                                     'Opacity Info
    End Sub

    Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
        Me.Opacity = TrackBar1.Value / 100                                      'Adjust Opacity With Trackbar
        Label1.Text = "% " & (Me.Opacity * 100)                                 'Opacity Info
    End Sub
End Class



Bye...

No comments:

Post a Comment