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...

Monday, January 27, 2014

Fugitive Buttons in Visual Basic 2010 / 2012 - Simple Codes

Hi,

Fugitive Buttons in Visual Basic, Insert 1 button in form. And paste the code;

Public Class Form1

    Dim try_count, val As Integer
    Dim rndm As New Random

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Size = New Size(My.Computer.Screen.WorkingArea.Width, My.Computer.Screen.WorkingArea.Height)
        Me.WindowState = FormWindowState.Maximized      'For fullscreen form
        Me.AcceptButton = Nothing
    End Sub

    Private Sub Button1_MouseMove(sender As Object, e As MouseEventArgs) Handles Button1.MouseMove

        Button1.Location = New Point(rndm.Next(170, Me.Size.Width - 170), rndm.Next(75, Me.Size.Height - 75))
        try_count = try_count + 1
        Me.Text = "Try : " & try_count.ToString

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        MsgBox("congratulations!", MsgBoxStyle.MsgBoxRight, "congratulations")

    End Sub

End Class

Good Bye...

Sunday, January 26, 2014

Adjust to Form Background Color in Visual Basic 2010 / 2012 - Simple Codes

Hi,

Make to optional form background color in Visual basic.

Method 1 :

Insert 1 button and 1 color dialogbox in form. And paste the code;



Public Class Form1
    Dim color1 As Color

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ColorDialog1.ShowDialog()
        color1 = ColorDialog1.Color
        MsgBox(color1.ToString)
        Me.BackColor = color1
    End Sub
End Class









Method 2:


Insert 1 Button and 5 radiobutton in form. And paste the code;


Public Class Form1
    Dim color1 As Color
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If RadioButton1.Checked Then color1 = Color.White
        If RadioButton2.Checked Then color1 = Color.Black
        If RadioButton3.Checked Then color1 = Color.Brown
        If RadioButton4.Checked Then color1 = Color.Pink
        If RadioButton5.Checked Then color1 = Color.Blue
        MsgBox(color1.ToString)
        Me.BackColor = color1
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        RadioButton1.Text = "White"
        RadioButton2.Text = "Black"
        RadioButton3.Text = "Brown"
        RadioButton4.Text = "Pink"
        RadioButton5.Text = "Blue"
    End Sub
End Class




Bye ...

Saturday, January 25, 2014

Marquee label in visual basic 2010 / 2012 Simple Codes

Hi for new project,

Again open Visual Basic and new project, insert 1 timer, 1 label and 1 trackbar. And code;

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TrackBar1.Maximum = 1000
        TrackBar1.Minimum = 1
        Timer1.Interval = 100
        Timer1.Start()

    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        Label1.Text = Label1.Text.Substring(1) + Label1.Text.Substring(0, 1)

    End Sub
    Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
        Timer1.Interval = TrackBar1.Value
    End Sub
End Class



By...

Friday, January 24, 2014

Digital Clock in Visual Basic 2010 / 2012 - Simple Codes

Hi,

We make Digital Clock with timer in Visual Basic.

Insert to 1 label and 1 timer in form1 and interval set 100. double click to timer1. paste this code ;


Label1.text=date.now.hour & "." & Date.now.minute & "." & Date.now.Second

ans double click form1. Paste this code ;

timer1.start

Done. F5 (RUN)


By...

Thursday, January 23, 2014

Open and close program for cd drive door - Simple Codes

Hi,

Cd door open and close program code in visual basic.

Start to Visual Studio 2012 for Visual Basic. New Project.

Let’s start,

İnsert to 2 button in form1

And paste this code;
---------------------------------------------------------------------------
Public Class Form1

    Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        mciExecute("Set CDAudio door Open")




    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        mciExecute("Set CDAudio door Closed")
    End Sub
End Class

------------------------------------------------------------------------------



By.