0% found this document useful (0 votes)
75 views8 pages

Controls

1. To open a new form in Visual Basic, right click on the project name in Solution Explorer and select Add > New Item to add a new Windows form. 2. To move between forms, create an instance of the new form and call the Show method while hiding the current form, such as Dim F2 As New Form2(): F2.Show(): Me.Hide(). 3. Common controls in Visual Basic forms include buttons, labels, textboxes, checkboxes, radiobuttons, combo boxes, date/time pickers, list boxes, and picture boxes. Dialog boxes can be used to open files, save files, select fonts and colors.

Uploaded by

Vipul Desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views8 pages

Controls

1. To open a new form in Visual Basic, right click on the project name in Solution Explorer and select Add > New Item to add a new Windows form. 2. To move between forms, create an instance of the new form and call the Show method while hiding the current form, such as Dim F2 As New Form2(): F2.Show(): Me.Hide(). 3. Common controls in Visual Basic forms include buttons, labels, textboxes, checkboxes, radiobuttons, combo boxes, date/time pickers, list boxes, and picture boxes. Dialog boxes can be used to open files, save files, select fonts and colors.

Uploaded by

Vipul Desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

[Link]

html
[Link]
TO OPEN A NEW WEB FORM
Right click on the project name in the solution explorer ->in the menu select add-
>new item->in the dialog box which opens select windows form and click add
to move from one form to another on click of button
Dim F2 As New Form2()
[Link]()
[Link]()
Button, label, textbox
Public Class Form1
Private Sub Button1_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
Dim a As *nte(er
Dim b As *nte(er
Dim c As *nte(er
+[Link] , [Link]
a , "al(-[Link].1.-e.t)
b , "al(-[Link].2.-e.t)
c , a / b
0abel2.-e.t , c.-oStrin(
'n# Sub
'n# Class
Check box election !"rou# box
Public Class Form2
Dim str As Strin(
Private Sub Button1_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
str , 1 1
*2 [Link] , 1 -hen
str , str / ChecBo.1.-e.t
+s(Bo.(1Chece# 11)
'n# *2
*2 [Link] , 1 -hen
str , str / ChecBo.2.-e.t
+s(Bo.(1Chece# 21)
'n# *2
*2 [Link] , 1 -hen
str , str / ChecBo.3.-e.t
+s(Bo.(1Chece# 31)
'n# *2
0abel1.-e.t , str
'n# Sub
'n# Class
Ra$ioButton Control
Public Class Form2
Dim str As Strin(

Private Sub Button1_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
*2 4a#[Link]# , -rue -hen
str , 4a#ioButton5.-e.t
'lse*2 4a#[Link]# , -rue -hen
str , 4a#ioButton6.-e.t

'n# *2
0abel1.-e.t , str
'n# Sub
Private Sub Button2_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
*2 4a#[Link]# , -rue -hen
BacColor , Color.4e#
str , 4a#ioButton1.-e.t
'lse*2 4a#[Link]# , -rue -hen
BacColor , Color.7reen
str , 4a#ioButton2.-e.t
'lse*2 4a#[Link]# , -rue -hen
BacColor , [Link]
str , 4a#ioButton3.-e.t

'n# *2
0abel2.-e.t , 1u selecte# 1 / vbNew0ine / str
'n# Sub
'n# Class
%ink %abel
O#en other form
Private Sub 0in0abel1_0inClice#(B!"al sen#er As S!stem.$b%ect& B!"al
e As S!stem.8in#[Link].0in0abel0inClice#'ventAr(s) )an#les
0in0abel1.0inClice#
Dim F2 As New Form1()
[Link]()
+e.)i#e()
'n# Sub
'n# Class
O#en &ebite
Private Sub 0in0abel1_0inClice#(B!"al sen#er As S!stem.$b%ect& B!"al
e As S!stem.8in#[Link].0in0abel0inClice#'ventAr(s) )an#les
0in0abel1.0inClice#
S![Link]([Link](1www.(oo(le.com1)
'n# Sub
'n# Class
Combo Box'
Public Class Form3

Private Sub ComboBo.1_Selecte#*n#[Link](e#(B!"al sen#er As S!stem.$b%ect&
B!"al e As S!stem.'ventAr(s) )an#les [Link]#*n#[Link](e#
0abel1.-e.t , 19 Selecte# : : 1 / [Link]#*tem

'n# Sub
'n# Class
(ate time Picker'
Private Sub Date-imePicer1_"alueChan(e#(B!"al sen#er As S!stem.$b%ect& B!"al
e As S!stem.'ventAr(s) )an#les Date-imePicer1."alueChan(e#

0abel1.-e.t , Date-imePicer1.-e.t ; onl! #ate(2ormat,short)we can also
customise the 2ormat b! chan(in( 2ormat,customn set value in custom2ormat ,
value
-[Link].1.-e.t , Date-imePicer1."alue ;2ull #ate with time
'n# Sub
%itbox'

Button:
Private Sub Button1_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
Dim *tem As Strin(
<1)ere are the multi=le selecte# items: 1
For 'ach *tem *n [Link]#*tems
0istBo.2.*tems.A##(*tem.-oStrin(())
Ne.t
8hile [Link]#*[Link] > ?
0istBo.1.*tems.4emove([Link]#*tem)
'n# 8hile

<sin(le selecte# item
*2 [Link]#*n#e. @> A1 -hen
0istBo.2.*tems.A##([Link]#*tem.-oStrin(())
*2 [Link]#*n#e. @> A1 -hen
0istBo.1.*tems.4emoveAt([Link]#*n#e.)
'n# *2
'n# *2
'n# Sub
On item click'
Private Sub 0istBo.1_Selecte#*n#[Link](e#(B!"al sen#er As S!stem.$b%ect& B!"al
e As S!stem.'ventAr(s) )an#les [Link]#*n#[Link](e#
<sin(le selecte#
*2 [Link]#*n#e. @> A1 -hen
0istBo.2.*tems.A##([Link]#*tem.-oStrin(())
*2 [Link]#*n#e. @> A1 -hen
0istBo.1.*tems.4emoveAt([Link]#*n#e.)
'n# *2
'n# *2
'n# Sub
Chan"in" #icture in #icture box uin" o#en)le $ialo" box'
Private Sub Button2_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
*2 $=enFileDialo([Link](() , Dialo(4esult.$B -hen
s , $=enFileDialo([Link]
-[Link].1.-e.t , s
PictureBo.1.*ma(e , *ma([Link](s)
'n# *2
'n# Sub
Workin" &ith $ialo" boxe'
*m=orts S!stem.*$
Public Class Form1
Private Sub Button1_Clic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les [Link]
[Link].1.-e.t , 1 1
<clears the te.t in [Link].
'n# Sub
Private FileName As Strin(
<#eclarin( 2ilename that will be selecte#
Dim sr As Stream4ea#er
<streamrea#er is use# to rea# te.t
Private Sub $=en-oolStri=+enu*tem_Clic(B!"al sen#er As S!stem.$b%ect&
B!"al e As S!stem.'ventAr(s) )an#les $=en-oolStri=+enu*[Link]
-r!
8ith $=enFileDialo(1
<8ith statement is use# to [Link] statements usin( a
=articular ob%ect& here&_
<$=enFileDialo(1
.Filter , 1-e.t 2iles (C.t.t)DC.t.tD1 E 1All 2ilesDC.C1
<settin( 2ilters so that -e.t 2iles an# All Files choice
a==ears in the Files o2 -!=e bo.
<in the #ialo(
*2 .ShowDialo(() , 8in#[Link](4esult.$B -hen
<showDialo( metho# maes the #ialo( bo. visible at run
time
FileName , .FileName
sr , New Stream4ea#er(.$=enFile)
<usin( streamrea#er to rea# the o=ene# te.t 2ile
[Link].1.-e.t , sr.4ea#-o'n#()
<#is=la!in( te.t 2rom streamrea#er in [Link].
'n# *2
'n# 8ith
Catch es As '.ce=tion
+essa(eBo..Show(es.+essa(e)
Finall!
*2 Not (sr *s Nothin() -hen
[Link]()
'n# *2
'n# -r!
'n# Sub
Private Sub Save-oolStri=+enu*tem_Clic(B!"al sen#er As S!stem.$b%ect&
B!"al e As S!stem.'ventAr(s) )an#les Save-oolStri=+enu*[Link]
Dim sw As Stream8riter
<streamwriter is use# to write te.t
-r!
8ith SaveFileDialo(1
.FileName , FileName
.Filter , 1-e.t 2iles (C.t.t)DC.t.tD1 E 1All 2ilesDC.C1
*2 .ShowDialo(() , 8in#[Link](4esult.$B -hen
FileName , .FileName
sw , New Stream8riter(FileName)
<usin( streamwriter to write te.t 2rom [Link]. an#
savin( it
sw.8rite([Link].1.-e.t)
'n# *2
'n# 8ith
Catch es As '.ce=tion
+essa(eBo..Show(es.+essa(e)
Finall!
*2 Not (sw *s Nothin() -hen
[Link]()
'n# *2
'n# -r!
'n# Sub
Private Sub Font-oolStri=+enu*tem_Clic(B!"al sen#er As S!stem.$b%ect&
B!"al e As S!stem.'ventAr(s) )an#les Font-oolStri=+enu*[Link]
-r!
8ith FontDialo(1
.Font , [Link]
<initialiFin( the #ialo( bo. to match the 2ont use# in the
[Link].
.Color , [Link]
<#e2ault color is Blac
*2 .ShowDialo( , 8in#[Link](4esult.$B -hen
setFont()
<callin( a metho# setFont() to set the selecte# 2ont an#
color
'n# *2
'n# 8ith
Catch es As '.ce=tion
+essa(eBo..Show(es.+essa(e)
'n# -r!
'n# Sub
Private Sub setFont()
-r!
8ith FontDialo(1
[Link] , .Font
*2 .ShowColor -hen
[Link] , .Color
<settin( the color
'n# *2
'n# 8ith
Catch e. As '.ce=tion
+essa(eBo..Show(e..+essa(e)
'n# -r!
'n# Sub
Private Sub Color-oolStri=+enu*tem_Clic(B!"al sen#er As S!stem.$b%ect&
B!"al e As S!stem.'ventAr(s) )an#les Color-oolStri=+enu*[Link]
Static CustomColors() As *nte(er , G47B(266& ?& ?)& 47B(?& 266& ?)&
47B(?& ?& 266)H
<initialiFin( CustomColors with an arra! o2 inte(ers an# =uttin( 4e#&
7reen&
<an# Blue in the custom colors section
-r!
8ith ColorDialo(1
.Color , [Link]
<initialiFin( the selecte# color to match the color currentl!
use#
<b! the [Link].<s 2ore(roun# color
.CustomColors , CustomColors
<2illin( custom colors on the #ialo( bo. with the arra!
#eclare# above
*2 .ShowDialo(() , 8in#[Link](4esult.$B -hen
[Link] , .Color
CustomColors , .CustomColors
<Storin( the custom colors to use a(ain
'n# *2
ColorDialo(1.4eset()
<resettin( all colors in the #ialo( bo.
'n# 8ith
Catch es As '.ce=tion
+essa(eBo..Show(es.+essa(e)
'n# -r!
'n# Sub
Private Sub Form1_0oa#(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les +!Base.0oa#
'n# Sub
'n# Class
Pro"re bar' (using timer)
Dim 22 As New Form2
Private Sub Form3_0oa#(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les +!Base.0oa#

Pro([Link]= , 21
Pro(ressBar1."alue , ?
Button5.'nable# , False
-imer1.'nable# , -rue
'n# Sub
Private Sub -imer1_-ic(B!"al sen#er As S!stem.$b%ect& B!"al e As
S!stem.'ventAr(s) )an#les -imer1.-ic

Pro(ressBar1.Per2ormSte=()
*2 Pro(ressBar1."alue >, Pro(ressBar1.+[Link] -hen
-imer1.'nable# , False
Button5.'nable# , -rue
[Link]()
+e.)i#e()
'n# *2
'n# Sub

You might also like