1. Creamos un nuevo formulario que llamaré Form1, dentro de este insertamos un ProgressBar, un timer, un botón y un Label cuyo texto será el numero 0.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
ProgressBar1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value = ProgressBar1.Value + 1
Label1.Text = CInt(Label1.Text) + 1
ProgressBar1.Style = ProgressBarStyle.Continuous
If CInt(ProgressBar1.Value) = 100 Then
Timer1.Stop()
Timer1.Enabled = False
Me.Hide()
Form2.Show()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Timer1.Interval = 100
End Sub
End Class
2. Agregamos un nuevo formulario que será Form2.
El mismo ejemplo pero con Form1 programado en C#
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void button1_Click(object
sender, EventArgs e)
{
timer1.Start();
}
private
void timer1_Tick(object
sender, EventArgs e)
{
progressBar1.Value =
progressBar1.Value + 1;
label1.Text = (Convert.ToInt32(label1.Text) + 1).ToString();
progressBar1.Style = ProgressBarStyle.Continuous;
if
(Convert.ToInt32(progressBar1.Value) == 100)
{
timer1.Stop();
timer1.Enabled = false;
this.Hide();
Form2
form2 = new Form2();
form2.Show();
}
}
}
}