visual Basic Assignment #1

Biswajit Bhunia

Assistant Teacher, Bankura Banga Vidyalay

my mail: biswajit62418@gmail.com 

Question:

Write a Program in VB to check whether a given number is Prime 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. Double Click on Command1

  5. Write the following Code-


PRIVATE SUB COMMAND1_CLICK()

DIM N,R,I AS INTEGER

N=VAL(TEXT1.TEXT)

R=0

FOR I=2 TO N/2

R=N MOD i

IF R=0 THEN 

  MSGBOX “NUMBER IS NOT PRIME”

  Exit sub

END IF

NEXT I

IF R=0 THEN

 MSGBOX “THE NUMBER IS NOT PRIME”

ELSE

MSGBOX “THE NUMBER IS PRIME”

ENDIF

END SUB


  1. Save the Project

File→Save Project→Save in→ Select Desktop→xi69.frm→Save→xi69.vbp→Save

  1. Run The Project

Press F5


Comments

Popular posts from this blog

Palindrome using Python

Bankura Banga Vidyalay Online ClassDetails