Professional Documents
Culture Documents
Visual Basic Programs
Visual Basic Programs
Private Sub Command1_Click() Print " I!"I" #nd Sub Private Sub Command2_Click() Print "BB$(C$%)" #nd Sub Private Sub Command&_Click() Print "''(1&4'1)11" #nd Sub Private Sub Command4_Click() Print "4T" S#%" #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a* b* r $+ Inte,er a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) r-a0b Te.t&/Te.t - r #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command2_Click() !im a* b* r $+ Inte,er a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) r-a1b Te.t&/Te.t - r #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command&_Click() !im a* b* r $+ Inte,er a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) r-a2b Te.t&/Te.t - r #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command4_Click() !im a* b* r $+ Inte,er a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) r-a3b Te.t&/Te.t - r #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a* b* c* . . - Val(Te.t1/Te.t) a-' b-1 Print a Print b 4or i - 1 To . c-a0b Print c a-b b-c e.t #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a $+ Inte,er a - Val(Te.t1/Te.t) 4or i - a To 1 Ste7 11 Print i e.t #nd Sub
00613401911
Nidhi Thareja
Private Sub Command1_Click() !im a $+ Inte,er a - Val(Te.t1/Te.t) !o a-a11 Print a 6oo7 89ile (a :- 1) #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
C) !o 89ile 6oo7
Private Sub Command1_Click() !im a $+ Inte,er a - 1'' !o 89ile (a :- 1) a-a11 Print a a-a11 6oo7 #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254 Program: Write a program to print 2s table by using : $) !o 6oo7 89ile
Private Sub Command1_Click() !im a $+ Inte,er a-' !o a-a02 Print a 6oo7 89ile (a ; 2') #nd Sub B) !o 89ile 6oo7
Private Sub Command1_Click() !im a $+ Inte,er a-2 !o 89ile (a ;- 2') Print a a-a02 6oo7 #nd Sub 00613401911 Nidhi Thareja
Private Sub Command1_Click() 4or a - 2 To 2' Ste7 2 Print a e.t #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254 Program : Write a program to show Factorial of the i!en "umber.
Private Sub Command1_Click() !im a* b $+ Inte,er a - Val(Te.t1/Te.t) b-1 4or i - a To 1 Ste7 11 b-i2b e.t Print b #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im $ $+ Inte,er $ - Val(Te.t1/Te.t) I< $ %od 2 - ' T9en %+,Bo. " T9e ,iven no/ i+ #ven" #l+e %+,Bo. " T9e ,iven no/ i+ =dd" #nd I< #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a $+ Inte,er a - Val(Te.t1/Te.t) I< (a %od 4 - ') T9en %+,Bo. " It i+ a 6ea7 >ear" #l+eI< (a %od 1'' - ') $nd (a %od 4'' - ') T9en %+,Bo. "It i+ a 6ea7 >ear" #l+e %+,Bo. " It i+ ot a 6ea7 >ear" #nd I< #nd Sub
00613401911 Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a* b $+ Inte,er a - Val(Te.t1/Te.t) b-a2a %+,Bo. "+?uare value i+ " @ b #nd Sub Private Sub Command2_Click() !im a* b $+ Inte,er a - Val(Te.t1/Te.t) b-a2a2a %+,Bo. "cube value i+ " @ b #nd Sub
00613401911 Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a* b* c $+ Inte,er a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) c - Val(Te.t&/Te.t) d - (a 0 b 0 c) 3 & %+,Bo. "T9e $vera,e o< ,iven no+/ i+ " @ d #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command2_Click() !im a* b* c $+ Inte,er a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) c - Val(Te.t&/Te.t) d - ((a 0 b 0 c) 3 &) 2 1'' %+,Bo. "T9e Percenta,e o< ,iven no+/ i+ " @ d #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a(1 To &* 1 To &) $+ Inte,er 4or i - 1 To & 4or A - 1 To & a(i* A) - i 0 1 0 A Print a(i* A)B e.t Print e.t #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command2_Click() !im a(1 To &* 1 To &) $+ Inte,er 4or i - 1 To & 4or A - 1 To & a(i* A) - i 1 1 1 A Print a(i* A)B e.t Print e.t #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command&_Click() !im a(1 To &* 1 To &) $+ Inte,er 4or i - 1 To & 4or A - 1 To & a(i* A) - i 2 1 2 A Print a(i* A)B e.t Print e.t #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im a (1to&) a+ inte,er 4or i-1 to & 4or A-1 to i Print C2DB e.t Print e.t #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Program : Write a program in VB to show the wor%ing of option buttons and chec%bo*es.
Private Sub Command1_Click() I< =7tion1/Value - True T9en %+,Bo. " >our Seme+ter i+ Second" #l+eI< =7tion2/Value - True T9en %+,Bo. ">our Seme+ter i+ 4ourt9" #l+eI< =7tion&/Value - True T9en %+,Bo. ">our Seme+ter i+ Si.t9" #l+e %+,Bo. "Plea+e +elect Eour +eme+ter" #nd I< #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() I< C9eck1/Value - 1 T9en %+,Bo. "4avourite Colour i+ Voilet" #l+eI< C9eck2/Value - 1 T9en %+,Bo. "4avourite Colour i+ Indi,o" #l+eI< ((C9eck1/Value - 1) $nd (C9eck2/Value - 1)) T9en %+,Bo. "4avourite Colour i+ Voilet @ Indi,o" #l+e %+,Bo. " Plea+e +elect Eour <avourite Colour" #nd I< #nd Sub
00613401911
Nidhi Thareja
Private Sub Command1_Click() !im a* b $+ Strin, a - Val(Te.t1/Te.t) b - Val(Te.t2/Te.t) I< (a - "nid9i") $nd (b - "t9areAa") T9en %+,Bo. "$ut9oriFed G+er" #l+e %+,Bo. "unaut9oriFed u+er" #nd I< #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
Private Sub Command1_Click() !im $ $+ Inte,er $ - Val(Te.t1/Te.t) Select Ca+e $ Ca+e 1 b - %+,Bo.("%ondaE") Ca+e 2 b - %+,Bo.("Tue+daE") Ca+e & b - %+,Bo.("8edne+daE") Ca+e 4 b - %+,Bo.("T9ur+daE") Ca+e 5 b - %+,Bo.("4ridaE") Ca+e ( b - %+,Bo.("SaturdaE") Ca+e H b - ("SundaE") Ca+e #l+e %+,Bo. ("Plea+e enter t9e IeekdaE no/ ") #nd Select #nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254 Program : Write a program to chec% if the gi!en number is Prime or "ot
Private Sub Command1_Click() !im a* b* c $+ Inte,er a - Val(Te.t1/Te.t) b-' c-2 I< (c ;- a 3 2) $nd (a %od c - ') T9en b-1 #nd I< c-c01 I< b - ' T9en %+,Bo. ("T9e no/ i+ Prime") #l+e %+,Bo. ("T9e no/ i+ ot Prime") #nd I<
#nd Sub
00613401911
Nidhi Thareja
Introduction To VB 254
00613401911
Nidhi Thareja
Introduction To VB 254
Writing Visual Basic code involves thinking visually, and thinking first about objects, rather than procedures. A form to receive user input is an object and likely contains other objects--its "children." ommand buttons, te!t bo!es and option buttons are all e!amples of controls you might find on a user form.
A natural conse"uence of programming #ith objects is choosing #hich events each object #ill respond to, and then choosing each object$s response to those events. %he follo#ing is a code fragment that represents a radio button$s &an object' response to the event of a user clicking it.
Another characteristic of Visual Basic is its WYSIWIG (what you see is what you get) form designer. You can create forms visually and uic!ly" while Visual Basic su##lies the s!eleton code $ehind your form and its controls. %reate a new form in Visual Basic through the menu item &'ro(ect ) Add Windows *orm.& You drag and dro# controls onto the form from a #alette of controls" which you then si+e and #osition according to your #ro(ect,s needs. Visual Basic remem$ers the settings you assign in the design window when you finally e-ecute your #rogram.
.ou$le/clic!ing each o$(ect in the designer window causes Visual Basic to create some s!eleton code for that o$(ect. Your (o$ is to fill in the $lan!s to ma!e the o$(ect do something. If you create a $utton control for your form" dou$le/clic! it while in the form design window. Visual Basic ta!es you to the su$routine $utton01%lic!. In that su$routine" you code what you want to ha##en when your #rogram,s users #ress the $utton during #rogram e-ecution.
00613401911
Nidhi Thareja
Introduction To VB 254
GUI Interface
VB i+ a Jra79ical G+er Inter<ace (JGI) lan,ua,e/ T9i+ mean+ t9at a VB 7ro,ram Iill alIaE+ +9oI +omet9in, on t9e +creen t9at t9e u+er can interact Iit9 (u+uallE via mou+e and keEboard) to ,et a Aob done/ T9e <ir+t +te7 in buildin, t9e VB 7ro,ram i+ to ,et t9e JGI item+ on t9e +creen/ T9i+ i+ done via 7ull1doIn menu+ t9at li+t t9e available ,ra79ical obAect+/ 4or e.am7le* i< t9e JGI item i+ a +Iitc9* le<t1 clickin, Iould alloI t9e 7ro,rammer to +aE 9oI bi, t9e +Iitc9 Ia+* 9oI it Ia+ labeled and I9ere on t9e +creen it i+ 7o+itioned/ Ki,9t1 clickin, on t9e +Iitc9 Iould brin, u7 a IindoI t9at alloI+ t9e 7ro,rammer to Irite t9e code t9at de+cribe+ I9at 9a77en+ I9en t9e u+er click+ t9e +Iitc9/
Macros IDE
T9e %acro+ inte,rated develo7ment environment (I!#) i+ +imilar in de+i,n and <unction to t9e Vi+ual Studio I!#/ T9e %acro+ I!# include+ a Code #ditor* tool IindoI+* t9e ProAect #.7lorer* #ditor and Pro7ertie+ IindoI+/ T9e di<<erence betIeen t9e %acro+ I!# and Vi+ual Studio+ I!# i+ t9at t9e %acro+ I!# a77lie+ to t9e code and 7roAect+ Iit9in t9e %acro+ environment.
00613401911
Nidhi Thareja
Introduction To VB 254
Types Of Projects
Windows &pplication ,emplate -lass .ibrary ,emplate -onsole &pplication ,emplate WPF &pplication WPF Browser &pplication G+ed to create 8indoI+1ba+ed a77lication+ t9at run locallE on u+er+L com7uter+/ >ou can build anEt9in, <rom a +im7le +in,le1IindoI tool like 8indoI+ Calculator to a com7lete a77lication t9at 9a+ multi7le IindoI+ and advanced ca7abilitie+/ G+ed to create reu+able cla++e+ or com7onent+ t9at can be +9ared Iit9 multi7le 7roAect+/ G+ed to create command1line a77lication+* 7ro,ram+ t9at run <rom a 8indoI+ command 7rom7t and 9ave no vi+ual inter<ace/ G+ed to create +tand1alone 8indoI+ Pre+entation 4oundation a77lication+/ G+ed to create broI+er19o+ted 8indoI+ Pre+entation 4oundation a77lication+/
00613401911
Nidhi Thareja
Introduction To VB 254
00613401911
Nidhi Thareja