Visual Basic Assignment #2
Biswajit Bhunia
Assistant Teacher, Bankura Banga Vidyalay
biswajit62418@gmail.com
Question:
Write a program to check whether a number is Odd or not
Ans.
Open Visual Basic 6.0
Start→Programs/All Programs→Microsoft Visual Studio 6.0→Microsoft Visual Basic 6.0
Select Standard EXE → Open
Take one Label(Label1) →Press F4→Caption→Enter any Number
Take one TextBox(Text1)→Press F4→Text→Press SpaceBar
Take on CommandButton(Command1)→Press F4→Caption
Take ANOTHER Label(Label2) →Press F4→Caption→THE nUMBER IS:
Double Click on Command1
Write the following Code-
PRIVATE SUB COMMAND1_CLICK()
DIM N,R,I AS INTEGER
N=VAL(TEXT1.TEXT)
R=N MOD 2
IF R=0 THEN
LABEL2.CAPTION= “NUMBER IS EVEN”
eLSE
LABEL2.CAPTION= “NUMBER IS “ODD”
END IF
END SUB
7. Save the Project
File→Save Project→Save in→ Select Desktop→xi0617.frm→Save→xi0617.vbp→Save
8. Run The Project
Press F5
Comments
Post a Comment