Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
254 views

Project

Visual Basic.NET is an object-oriented, event-driven programming language that works with the .NET Framework to create applications like forms, web services, and console applications. The .NET Framework provides a common language runtime (CLR) that executes and manages code, as well as a class library. Compilers translate code into Microsoft intermediate language (MSIL) code, which the CLR then compiles to native machine code. Developers typically use Microsoft Visual Studio, an integrated development environment, to create and debug VB.NET applications that produce assemblies to run on the .NET Framework.

Uploaded by

Vikas Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
254 views

Project

Visual Basic.NET is an object-oriented, event-driven programming language that works with the .NET Framework to create applications like forms, web services, and console applications. The .NET Framework provides a common language runtime (CLR) that executes and manages code, as well as a class library. Compilers translate code into Microsoft intermediate language (MSIL) code, which the CLR then compiles to native machine code. Developers typically use Microsoft Visual Studio, an integrated development environment, to create and debug VB.NET applications that produce assemblies to run on the .NET Framework.

Uploaded by

Vikas Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

TABLE

OF

CONTENTS

VB.NET
Programming........................................2

.NET FRAMEWORK............................................3
CLR (Common Language Runtime).........................................5
MSIL (Microsoft Intermediate Language)..................7
Common Language Specification..............................7
.NET Framework Class Library.................................................8
.NET Assemblies......................................................9

MICROSOFT VISUAL STUDIO............................. 13


CREATING VISUAL BASIC.NET APPLICATION

WITH

MICROSOFT VISUAL STUDIO............................. 16

Page 1 of 27

Page 2 of 27

V B .Net Programming

B.Net (Visual Basic.Net) ,d Object Oreinted1, Event Driven2

dEI;wVj izksxzkfeax Hkk"kk gS] tks .Net


Framework ds lkFk dk;Z djrs gq;s applications tSls

forms, presentation foundation, class libraries and console-based applications

cukus ds fy;s ,d dynamic interface3 iznku djrh gSA VB.Net


Hkk"kk dks pykus ds fy;s .Net Framework ;qDr Developer Tool
dks iz;qDr djuk gh mfpr gSA bl gsrq ge Microsoft ds
IDE (Integrated Development Environment) ;qDr Microsoft Visual

Studio dk mi;ksx djrs gSaA


VB.Net fofHkUu QhplZ j[krk gS tSls%
Inheritance
Parameterized Class Constructors
1 Object oriented: Those languages, which use objects like textbox, label etc
for creating applications instead of commands.
2 Event driven : Those languages, which attach any action like mouseover,
click or key pressing with their object to trigger any event.
3 Dynamic interface can modify its objects without reopening application or
webpage.
Page 3 of 27

Function Overloading
Multi-Threading
Structured Error Handling
Creating NT Services
VB.NET not backward compatible with VB 6.
VB.Net ds ckjs esa foLrkj ls tkuus ls igys ge dqN

egRoiw.kZ fcanqvkas ij tkudkjh izkIr djrs gSaA


.Net Framework
Microsoft Visual Studio

.Net Framework
.Net Framework ekbkslkWV ds vuqlkj ,d u;k

dEI;wfVax IysVQkWeZ gSA bl IysVQkWeZ us mPp


Lrj ds fMfLVC;wVsM okrkoj.k esa cgqr gh ljyrk
ls ,Iyhds'ku cukus dh lqfo/kk iznku dh gSA ;g
IysVQkWeZ

izksxzkejkas

dks

,slh

lqfo/kk;as

miyC/k djkrk gS] ftlesa midj.k vkSj nwljs flLVe dh


Page 4 of 27

ckm.Mht lekIr gks tkrh gSaA bldh eq[; fo'ks"krk,


fuEu gSa%
CLR (Common Language Runtime)
MSIL
below
Windows Form
Web Services
Cross Language Interoperability4
.Net framework fofHkUu izdkj dh ,sIyhds'kUl tSls
Windows Applications, Mobile Apps, Web Apps, Components, XML Web Services 5

vkfn cukus ds fy;s loksZRre IysVQkeZ gSA


.Net Platform, Language Neutral gksus dk nkok djrk gSA .Net
Environment CLR vkSj ykbczsfj;kas ds lsV ds vklikl gh

dsafnzr jgrk gSA CLR ds vuq:i Hkk"kk vius dksMkas


dks vius ewy dksMkas dh ctk; baVjehfM,V Hkk"kk
esa rS;kj djrh gS vkSj fQj ;g baVjehfM,V Hkk"kk

4 Cross Language Interoperability: Inherit another language's coding in an


application with one language.
5 XML Web Services : .Net Framework avails creating XML Schema Definitions
for databases.
Page 5 of 27

(MSIL) bu dksMksa dks Native Machine Code esa cny nsrh

gSA
VB.Net dk mi;ksx djrs le; vki fdlh Hkh nwljh

izksxzkfeax Hkk"kk ds dksM blesa fcuk fdlh fnDdr


ds 'kkfey dj ldrs gSa] D;kasfd ;s lHkh .Net Object gSa]
vkSj vkil esa ,d nwljs ls tqM+s gSaA ,slk blfy;s
laHko gks ikrk gS] D;kasfd VB.Net vius Native Code ds
ctk; igys MSIL ls tqM+rk gS] vkSj fQj Native Code lsA bu
Intermediate Codes dks Managed Codes dgk tkrk gSA
.Net Framework SDK ds ,d fgLls ds :i esa command-line
compiler, VBC.EXE Hkh install gksrk gSA
.Net Framework ds nks eq[; components gSa%
1. CLR
2. .Net Framework Class Library

Page 6 of 27

CLR (Common Language Runtime)


tSlk fd uke ls Li"V gS] CLR ,d ,slk ek/;e iznku djrk
gS] tks fd lHkh .Net Languages ds fy;s common gSA CLR gh
application ds execution vkSj dbZ dk;Z tSls memory management,
system resources dks access djus] security services vkfn ds fy;s

ftEesnkj gSA bl izdkj dh O;oLFkk fofHkUu Win32


izksxzkfeax Hkk"kkvkas ds chp dk varjky [kRe dj
nsrh gS] D;kasfd lHkh .Net Languages dh ,d lh gh
laHkkouk, gksrh gSaA blds vykok Common Language
Runtime, applications dks ,d managed environment ds vanj run gksuk

nsrk gSA .Net esa cukbZ xbZ executabls dks CLR vyx ls
invoke djus ds ctk; Lo;a gh invoke djrk gSA

CLR Architecture
CLR ds 3 eq[; vax gSa%
1. Common Type System
2. MSIL
3. Managed Apps
Page 7 of 27

blds lkFk gh fofHkUu vU; dEiksusUV~l feydj CLR


dks dk;Z;ksX; cukrs gSaA

Figure 1. CLR Structure

fuEu xq.kkas ls ;qDr gksus ds dkj.k CLR izeq[k


gS%
a.

Running code eSust djuk


a. Type Safety6 verify djrk gSA

6 Type Safety: One language should not cross with other language's data type.
Page 8 of 27

b. Garbage Collection7 o error handling dh lqfo/kk iznku


djrk gSA
c. Semi-trusted code ds fy;s code access eas lqj{kk

b.

iznku djrk gSA


Common Type System8 dh lqfo/kk

a. Value Types (interger, float, user defined, etc)


b. Objects, Interfaces
c.

System Resources ij access iznku djukA


a. Native API, COM interop, etc.

MSIL (Microsoft Intermediate Language)

MSIL vFkkZr~ Microsoft Intermediate Language ,d high-level assembly


programming language gS] tks fd object-oriented gS o CPU independent
set of instructions provide djrh gS u fd CPU-dependent sets of instructions

dks ykxw djus okyh executables cukrh gSA MSIL bl izdkj


dh ,d dkWeu Hkk"kk gS fd ,d ls izksxzkfeax VkLDl
vyx vyx Hkk"kkvksa ls fy[kus ij Hkh ,d tSlk IL code
iznku djrs gSaA

7 Garbage Collection: Extra codes that are not going to execute on CPU.
8 Common Type System: .Net framework languages share same data types.
Page 9 of 27

Metadata, code esa ykxw fd;s x;s types ls tqM+k set of


information gSA bl izdkj dh tkudkjh signatures, functions o
procedures, members in types, and members in externally referenced types j[k

ldrh gSA Metadata dk ms'; code dks .Net Framework dks describe
djuk gSA
Common Language Specification

CLS ,d fu;ekas dk set gS] tks mu features dks specify djrk

gS] tks lHkh Hkk"kkvkas ds fy;s support djus pkfg;sA


bldk eq[; ms'; .NET framework dks multiple languages support djus
nsuk gSA CLS, ,sls features vkSj usage conventions ftuds ij
fuHkZj fd;k tk ldrk gS ds ckjs esa] Language designers
vkSj Dykl ykbczsjh ds e/; le>kSrk ,d agreement gSA
tSls fd public names dks case ij fuHkZj ugha djuk pkfg;s]
D;aksfd dbZ Hkk"kk, case sensitive ugha gksrhA bldk
vFkZ ;g ugha gS fd CLR ds ij lHkh Hkk"kk, case
sensitive ugha gSaA

Page 10 of 27

.NET Framework Class Library


Class Library, .Net Framework dk ,d egRoiw.kZ dEiksusaV

gSA blesa ,sls iwoZ fu/kkZfjr classes dk lewg gksrk


gS] ftudk iz;ksx dkWeu f;kdykikas ds fy;s izR;sd
LFkku ij fd;k tk ldrk gSA bl Class Library dh otg ls
MsoyilZ dks dbZ dslkas eas cgqr lqfo/kk gksrh
gSA bu classes dks fofHkUu dk;ksZa ds fy;s bLrseky
fd;k tkrk gSA .Net Framework eas Class Library, Namespace, Object
Groups esa vjsat gksrh gS] rkfd ,d tSls QaD'ku dj

ldsaA Namespace ds varxZr structures, delegates, interfaces Hkh


lekfgr gksrs gSaA .Net Framework Class Library esa yxHkx
100 Namespace gksrs gSaA
.Net Framework dh ykbczsjh cgqr gh foLr`r vkSj self
describing gSA ;g 2500 ls Hkh vf/kd classes j[krk gSA ;g

ykbczsjh form-oriented gksrh gSA ;g Windows GUI-based9 client


applications dks vklkuh ls cukus dh lqfo/kk iznku djrh
9 GUI Based : Graphical User Interface based
Page 11 of 27

gSA Standard GUI components tSls buttons, textboxes, menus, scrollbars, etc.
vkfn event handling ds lkFk QkWeZ esa Mkys tk ldrs
gSaA blds eq[; components,
Base Class: Networking, security, I/O, files, etc. Data and XML Classes
Web Services/UI

Windows UI gSA

.NET Assemblies

tc .Net, Codes dks ;wfuV esa xzqi djrh gS] rks bls
Assemblies dgk tkrk gSA Assembly esa ,d flaxy Qkby

gksrh gS] ;k dEiksusaV gksrs gS] tks eYVhiy


Qkbykas esa fMLVhC;wV gksrs gSaA bu leLr
dslkas esa ,d Q kby assembly manifest dh gksrh gS] tks
self-describing gksrh gSA
ClassicWin32 development environments esa tSls fd VB 6, Visual C++ ]

lkWlZ dksMZ dks dEikbylZ }kjk parse fd;k tkrk gS]


tks fd binary executable files cukrs gSa] tks fd rqjar
baVjizsV djds vkWijsfVax flLVe }kjk ju dh tk ldrh
Page 12 of 27

gSA okLro esa VB 6 vkSj C++ ds lkFk cukbZ xbZ win32


apps runtime dk mi;ksx djrh gSaA ijarq ;fn vkids ikl

fofHkUu izksxzkfeax Hkk"kkvkas ds lkFk cukbZ


xbZ ,sIyhds'ku gS] rc vkidks muds fy;s fuf'pr
runtimes dks baLVkWy djuk gksxkA .Net development esa

pkgs fdlh Hkh .Net Language ds lkFk vki ,Iyhds'ku


cuk;s] compilers }kjk ,d vlsEcyh cukbZ tkrh gS] tks fd
,d .Net executable code gksrh gS] vkSj vko';d :i ls MSIL code
vkSj metadata ds }kjk compose dh tkrh gSA

bl izdkj lHkh .Net framework ds dEiksusUV~l feydj fuEu


izf;k ds QyLo:i ,sIyhds'ku dks ju djrs gSa%
1-

fdlh Hkh Hkk"kk esa cuk;h x;s ,sIyhds'ku ds


dksM dks ml Hkk"kk ds gh dEikykbj }kjk CTS
(Common Type System) ds nk;js esa jgrs gq;s assembly IL
code (MSIL) esa dEikby djrk gSA bu dksM~l dks
managed codes dgrs gSaA vfrfjDr unmanaged code lh/ks
Page 13 of 27

Operating system ij execute gksrs gSa rFkk Managed Code CLR ij


execution ds fy;s Hkstk tkrk gSA CLR, execution ds le;

vko';d lHkh fjlkslsZl o Dyklsl dh ,Dlsl iznku


djrk gSA dksM dks Just-In-Time Compiler }kjk Native code
esa compile fd;k tkrk gSA ;g dksM OS dks Hkstk
tkrk gSA

Page 14 of 27

Li"V gS fd .Net framework Language o C P U Independent gSA


D;kasfd lHkh language ds dEikbyj MSIL vFkkZr~ ,d gh
Hkk"kk esa compile djrs gSa] ftlls code gj Hkk"kk ds
fy;s ogh jgrk gSA lkFk gh CLR }kjk dEikby dksM
native code esa compile gksrk gS] tks fd operating system dks

Page 15 of 27

Figure 2. How .Net Framework works with codes


using its components (executing and running codes)

CPU independent instructions set nsrk gSA ;s instruction set CPU }kjk
execute fd;s tkrs gSaA

Figure 3. .Net is CPU/Language Independent

Page 16 of 27

Microsoft Visual Studio


VB.Net ds lkFk ,Iyhds'kUl cukus ds fy;s vf/kdrj MS
Visual Studio dk gh iz;ksx fd;k tkrk gSA bl izksQs'kuy

MsoyiesaV Vwy eas ,Iyhds'kUl dks fMtkbu djus ds


fy;s VwYl dk lewg gksrk gS] vkSj lkFk gh fMcfxax
ds fy;s Hkh VwYl lekfgr gksrs gSaA
bu VwYl esa d`f=e cqf)erk dk lekos'k gksrk
gS] ftlls vusd xyfr;k vius vki gh lekIr gks tkrh
gSaaA dksM Vkbi djrs le; lts'ku Hkh lkeus vkrs
gSaA VS (Visual Studio) esa vusd ,sls VwYl vkSj
,M&vkWu gksrs gSa] ftudh lgk;rk ls vki lkWVos;j
dh tkp cM+h ljyrk ls dj ldrs gSaA

Page 17 of 27

VS dh esu Lhu fp=kuqlkj fn[kkbZ nsrh gSA


Standard Toolbar
Menu Bar
Toolbox

Solution Explorer

Tabs Bar
Working Area

Properties

Error List
Status Bar

Figure 4. Visual Studio Interface

Figure 5. .Net Framework and Visual Studio.Net

xsd

Page 18 of 27

Creating Visual Basic.Net Application with


Microsoft Visual Studio
VB.net dks testify djus ds fy;s Microsoft Visual Studio 2008
Professional Edition o Microsoft .NET Framework Version 3.5 SP1 dk mi;ksx

fd;k x;k gSA


Visual Studio esa izkstsDV 'kq: djus ds fy;s File Menu ds
New->project ij tk;saA
Project Type esa Windows ij fDyd djasA Templates esa Windows
Forms Application dk p;u djasA

okafNr Name, Location o Solution Name Hkjas o OK ij fDyd djsaA


vc Form 1 uke ls ,d QkWeZ lkeus vk tk;sxkA
Solution explorer esa windowsformapplication1 (In this project Calculator) ds ij
right fDyd djds properties option ij fDyd djus ij fofHkUu
properties eksfMQkbZ dj ldrs gSaA
Page 19 of 27

Page 20 of 27

Properties dk n`'; bl izdkj gksrk gS%

Form 1 esa VwyckWDl dk mi;ksx djds textbox insert djrs

gSa]

mls

properties

}kjk

uke

(LCD)

nsrs

gSaA

VwyckWDl dk mi;ksx djds buttons bulVZ djrs gSaA

Page 21 of 27

fdlh Hkh daVksy ds ij double click djds Backhand Codings dh


tk ldrh gSaA bl izkstsDV esa form 1 ds daVksYl ds
ij dh xbZ gSa] os gSa%
Public Class Calculator
Dim FirstNumber As Double
Dim temp As Double
Dim Operation As String
Dim Result As Double
Private Sub aboutform()
End Sub
Private Sub bequal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bequal.Click
Dim SecondNumber As Long
SecondNumber = LCD.Text
If Operation = "+" Then
Result = FirstNumber + SecondNumber
ElseIf Operation = "-" Then
Result = FirstNumber - SecondNumber
ElseIf Operation = "*" Then
Result = FirstNumber * SecondNumber
ElseIf Operation = "/" Then
Result = FirstNumber / SecondNumber
End If
FirstNumber = Result
LCD.Text = Result
End Sub
Private Sub n1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles n1.Click
If LCD.Text = "0" Then
LCD.Text = "1"
ElseIf LCD.Text = temp Then
LCD.Text = "1"
ElseIf LCD.Text = result Then
LCD.Text = "1"
Else
LCD.Text = LCD.Text & "1"
End If
End Sub
Private Sub n2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles n2.Click
If LCD.Text = "0" Then
LCD.Text = "2"
ElseIf LCD.Text = temp Then
LCD.Text = "2"
ElseIf LCD.Text = result Then
LCD.Text = "2"
Else

Page 22 of 27

LCD.Text = LCD.Text & "2"


End If
End Sub
Private Sub n3_Click(ByVal sender
System.EventArgs) Handles n3.Click
If LCD.Text = "0" Then
LCD.Text = "3"
ElseIf LCD.Text = temp Then
LCD.Text = "3"
ElseIf LCD.Text = result Then
LCD.Text = "3"
Else
LCD.Text = LCD.Text & "3"
End If
End Sub
Private Sub n4_Click(ByVal sender
System.EventArgs) Handles n4.Click
If LCD.Text = "0" Then
LCD.Text = "4"
ElseIf LCD.Text = temp Then
LCD.Text = "4"
ElseIf LCD.Text = result Then
LCD.Text = "4"
Else
LCD.Text = LCD.Text & "4"
End If
End Sub
Private Sub n5_Click(ByVal sender
System.EventArgs) Handles n5.Click
If LCD.Text = "0" Then
LCD.Text = "5"
ElseIf LCD.Text = temp Then
LCD.Text = "5"
ElseIf LCD.Text = result Then
LCD.Text = "5"
Else
LCD.Text = LCD.Text & "5"
End If
End Sub
Private Sub n6_Click(ByVal sender
System.EventArgs) Handles n6.Click
If LCD.Text = "0" Then
LCD.Text = "6"
ElseIf LCD.Text = temp Then
LCD.Text = "6"
ElseIf LCD.Text = result Then
LCD.Text = "6"
Else
LCD.Text = LCD.Text & "6"
End If
End Sub
Private Sub n7_Click(ByVal sender
System.EventArgs) Handles n7.Click
If LCD.Text = "0" Then
LCD.Text = "7"
ElseIf LCD.Text = temp Then
LCD.Text = "7"
ElseIf LCD.Text = result Then
LCD.Text = "7"
Else
LCD.Text = LCD.Text & "7"

As System.Object, ByVal e As

As System.Object, ByVal e As

As System.Object, ByVal e As

As System.Object, ByVal e As

As System.Object, ByVal e As

Page 23 of 27

End If
End Sub
Private Sub n8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles n8.Click
If LCD.Text = "0" Then
LCD.Text = "8"
ElseIf LCD.Text = temp Then
LCD.Text = "8"
ElseIf LCD.Text = result Then
LCD.Text = "8"
Else
LCD.Text = LCD.Text & "8"
End If
End Sub
Private Sub n9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles n9.Click
If LCD.Text = "0" Then
LCD.Text = "9"
ElseIf LCD.Text = temp Then
LCD.Text = "9"
ElseIf LCD.Text = result Then
LCD.Text = "9"
Else
LCD.Text = LCD.Text & "9"
End If
End Sub
Private Sub n0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles n0.Click
If LCD.Text = "0" Then
LCD.Text = "0"
ElseIf LCD.Text = temp Then
LCD.Text = "0"
ElseIf LCD.Text = result Then
LCD.Text = "0"
Else
LCD.Text = LCD.Text & "0"
End If
End Sub
Private Sub bc_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bc.Click
If LCD.Text = "0" Then
LCD.Text = "0"
ElseIf LCD.Text = temp Then
LCD.Text = "0"
Else
LCD.Text = LCD.Text & "00"
End If
End Sub
Private Sub bac_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bac.Click
LCD.Text = "0"
End Sub
Private Sub badd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles badd.Click
FirstNumber = LCD.Text
temp = FirstNumber
Operation = "+"
End Sub
Private Sub bsub_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bsub.Click
FirstNumber = LCD.Text

Page 24 of 27

temp = FirstNumber
Operation = "-"
End Sub
Private Sub bmult_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bmult.Click
FirstNumber = LCD.Text
temp = FirstNumber
Operation = "*"
End Sub
Private Sub bdiv_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bdiv.Click
FirstNumber = LCD.Text
temp = FirstNumber
Operation = "/"
End Sub
Private Sub Calculator_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub babout_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles babout.Click
AboutBox1.Show()
End Sub
End Class

bu lHkh steps dks iw.kZ djds] ,d u;k QkWeZ aboutbox1


cukrs gSaA blds fy;s s project > Add windows form esa tkrs
gSaA Common Items esa about box dks flysDV djrs gSaA

vc mldh fofHkUu properties igys gh fn;s gq;s rjhds ls


edit djrs gSaA

Page 25 of 27

u;s QkWeZ dk n`';%

,d vU; QkWeZ splansh screen Hkh cukrs gSa] ftldh


properties cnyrs gSa vkSj bl izdkj (complete fd;k gqvk)

fn[krk gSA ;g bl izdkj cuk;k x;k gS fd 5 lsds.M ckn


Lo;a dh gV tkrk gS ,oa form 1 (calculator) iznf'kZr djrk
gSA

bl izdkj iw.kZ fd;k x;k izkstsDV fuEu LhUl j[krk


gS%
Page 26 of 27

1. Splash Screen

2. Form1 (Name : Calculator)

3.
4. Aboutbox1 (Name : About Calculator)

5.

bl izdkj gekjk izkstsDV calculator iw.kZ gqvkA bls build


o publish dj bldk installation setup Hkh cuk;k tk ldrk gSA
blds fy;s build > Publish ij tk;asA

Page 27 of 27

You might also like