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

StartPrograms/All ProgramsMicrosoft Visual Studio 6.0Microsoft Visual Basic 6.0

Select Standard EXE Open

  1. Take one Label(Label1) Press F4CaptionEnter any Number

  2. Take one  TextBox(Text1)Press F4TextPress SpaceBar

  3. Take on CommandButton(Command1)Press F4Caption

  4. Take ANOTHER Label(Label2) Press F4CaptionTHE 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

FileSave ProjectSave in Select Desktopxi0617.frmSavexi0617.vbpSave

8. Run The Project

Press F5


Comments