Documente Academic
Documente Profesional
Documente Cultură
These controls
includeFlowLayoutPanel,TableLayoutPanel,GroupBox,Panel,TabControl,
andSplitContainer.
Meaning, each page is acontrol container, holding whatever controls you want for that
tab. When youclicka tab at design time or the user clicks one at runtime, the control
displays thecorresponding page.
The TabControl works fine if the data falls intonatural groupingsthat you can use for the
tab pages, but it doesn't work so well if the user must frequentlycompare valueson one
page with those on another, thatforcesthe user to jump back and forth.
?
1 Private Sub TabControl1_SelectedIndexChanged(sender As Object,
2 e As EventArgs) _
3 Handles TabControl1.SelectedIndexChanged
4 If TabControl1.SelectedIndex = 2 Then
5 Dim pic As New PictureBox
6 pic.Name = "Logo"
7 pic.Height = 100
8 pic.Width = 100
9 pic.Image = My.Resources.logo
1 pic.Location = New Point(20, 100)
0 TabControl1.TabPages(2).Controls.Add(pic)
1 '
1 End If
1 End Sub
2
"
These controls
includeFlowLayoutPanel,TableLayoutPanel,GroupBox,Panel,TabControl,
andSplitContainer.
"
This tutorial will show you how to make a stopwatch in visual basic:
To do that right click on the label and click on properties. In the properties window, change
the text as follows:
"
Change the font's size of the label. In the properties window, go to Font:
"
The font dialog will show up. Under the size, choose the number 28 then click Ok:
"
In the toolbox, drag the timer to the form. The timer will appear in the gray area below the
form:
"
Right click on Timer1 and click on properties. In the properties window, change the interval
property to 1.
"
Drag a listbox from the toolbox and place on the form as the picture below:
"
Right click on the form and click on View Code. Add the following declaration
belowPublic Class Form1
?
1 Private stopwatch As New Stopwatch
You can change the properties of Timer as needed, right click on it and click on Properties:
If you set Enabled to True, Timer will start ticking as soon as the form loads. Default is
False.
You can start the timer in your code. If you want to start the timer when you click a button
for example:
?
1 Private Sub Button1_Click(sender As System.Object, e As
2 System.EventArgs) _
3 Handles Button1.Click
4 Timer1.Start()
5 End Sub
6 To stop it:
Timer1.Stop()
To do things while timer is ticking, double click on the timer control, it should add the
Timer.Tick event for you:
?
1 Private Sub Timer1_Tick(sender As System.Object, e As
2 System.EventArgs) _
3 Handles Timer1.Tick
4 ' Add your code here
End Sub
Double Click the button and add the following code to the button click event:
?
1 Timer1.Interval = TextBox1.Text
Change the 12 labels text properties to the clock 12 hours. Change also the BackColor
property to white:
Add another label to the form and name it "time"
Note: Change the form WindowState property to Maximum to better see the clock
working