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.

  1. Open Visual Basic 6.0

Start→Programs/All Programs→Microsoft Visual Studio 6.0→Microsoft Visual Basic 6.0

Select Standard EXE → Open

  1. Take one Label(Label1) →Press F4→Caption→Enter any Number

  2. Take one  TextBox(Text1)→Press F4→Text→Press SpaceBar

  3. Take on CommandButton(Command1)→Press F4→Caption

  4. Take ANOTHER Label(Label2) →Press F4→Caption→THE nUMBER IS:

  5. 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

Popular posts from this blog

Bankura Banga Vidyalay Online ClassDetails

Palindrome using Python