answersLogoWhite

0


Best Answer

Private Sub Command1_Click()

Dim x,g,n,i,sum as Integer

n=Val(Text1.Text)

x=0

y=1

Print x

Print y

for i=3 To n

Sum = x + y

Print Sum

x = y

y = Sum

Next i

End Sub

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Prime number between 1 to 100

Dim flag As Boolean

flag =

True

BulletedList1.Items.Add(1)

BulletedList1.Items.Add(2)

For i = 1 To 1000

For J = 2 To i - 1

If (i Mod J = 0) Then

flag =

True

Exit For

Else

flag =

False

End If

Next

If flag = False Then

BulletedList1.Items.Add(i)

End If

Next i

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

good question! I'll write it in semi-program lingo, so you can translate it to visual basic language yourself later.

Fibonacci = 1,1,2,3,5,8,13,21 etc.

x = 1

y = 1

print x, print y

loop(parameters) //loop this function

}

z = x+y

print z

x = y

y = z

{

In this, you start with 1 and 1, then add them together and display that number. Then you set y equal to that number, and x equal to the number behind it. then repeat that.

This should give you the Fibonacci sequence.

-Jp

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Private Sub Command1_Click()

Dim fibonacci(10) As Long

Dim i As Integer

fibonacci(1) = 1

fibonacci(2) = 1

For i = 3 To 10

fibonacci(i) = fibonacci(i - 1) + fibonacci(i - 2)

Next i

For i = 1 To 10

Print fibonacci(i)

Next i

End Sub

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Here's a simple, recursive Scheme procedure to find the nth Fibonacci number (n >= 0):

(define (fib n)(if (< n 2)n(+ (fib (- n 1)) (fib (- n 2)))))

The same algorithm in C:

unsigned fib(unsigned n) {return (n < 2) ? n : (fib(n - 1) + fib(n - 2));}

Note, there are much more efficient (but less easy to understand) ways of generating this sequence.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Dim arr()

ReDim arr(10)

arr(0)=0

arr(1)=1

For k=2 to UBound(arr)

arr(k)=arr(k-1) + arr(k-2)

Next

For k=0 to UBound(arr)

Print arr(k)

Next

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Public

Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim I, N As Integer

N = InputBox(

"Enter number")

For I = 2 To N - 1

If N Mod I = 0 Then

MsgBox(

"THE NUMBER IS NOT A PRIME NUMBER")

Exit Sub

End If

Next I

If I = N Then

MsgBox(

"THE NUMBER IS A PRIME NUMBER")

End If

End sub

End class

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Imports System.Console

Module fabonacci

Dim n, a, b, i, c, t As System.Int32

Sub main()

WriteLine("enter the number")

n = Console.ReadLine()

WriteLine("Fabonacci Series ....")

a = 0

b = 1

WriteLine(a)

WriteLine(b)

i = 0

While (i < n - 2)

c = a + b

WriteLine(c)

t = a

a = b

b = c

i = i + 1

End While

ReadLine()

End Sub

End Module

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim N, I As Integer

N = Val(TextBox1.Text)

For I = 2 To N - 1

If I Mod N = 0 Then

Label3.Text = "not prime"

Else

Label3.Text = "prime"

End If

Next

End Sub

End Class

This answer is:
User Avatar

User Avatar

Wiki User

11y ago
  1. Let x = 1, let y = 0.
  2. Print x.
  3. Let x = y + x
  4. Let y = x - y
  5. Repeat from 2.

Public Sub Main() Dim X As Integer Dim Y As Integer Dim cnt As Integer 'Our counter. cnt = 1 Do While cnt < 8 Debug.Print X X = Y + X Y = X - Y cnt = cnt + 1 Loop End Sub

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in visual basic of prime numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you write a program in visual foxpro?

Same with other Visual Basic program, programming in FoxPro will require you to have the right syntax.


What is Visual Basic Editor?

There have been many versions of Visual Basic. It is a program which allows you to write other computer programs. Each version of Visual Basic has come with an editor to allow you to write and edit code. This is called the "IDE", or "Integrated Development Environment".


Program to print all the even numbers of an array in visual basic?

find even number in array


Can you run a Visual Basic program from a Website?

In general principles, you can not run a visual basic compiled program from a website. Visual basic compiled program needs the library files required to run the application. So only when you install the application locally (onto your machine), the application can be executed.


What are the steps involved in creating visual basic programs?

The traditional way to learn any programming language is to start by writing a "Hello, World" program; this program should write "Hello, World" to the screen. To write such a program, you have to work out how to edit text, and run it through the compiler. Visual Basic, is almost like that, but window environment programs are event driven - they consist of routines that react to events - a button being clicked, a timer expering and so on. Visual Basic is also object orientated. Windows, buttons, every component of a program are objects or part of objects. With this in mind, its useful to read up on events and objects to see how to approach Visual programming. With a little knowledge, think of a project and try and write a program. Writing programs is by far the quickest way to become proficient in a language.

Related questions

What has the author John Smiley written?

John Smiley has written: 'Learn to Program Databases With Visual Basic (Learn to Program)' 'Learn to Program Visual Basic Objects (Learn to Program)' 'Learn to Program with Visual Basic 6' -- subject(s): BASIC (Computer program language), Microsoft Visual BASIC, Visual Basic (Computer program), Visual programming (Computer science), Windows (Computer programs) 'Learn to Program Visual Basic 6 Examples' 'Introduction to Programming with Visual Basic 6 Part 2' 'Learn to Program Visual Basic Examples (Miscellaneous)' -- subject(s): Microsoft Visual Basic for Windows, BASIC (Computer program language)


How do you write a program in visual foxpro?

Same with other Visual Basic program, programming in FoxPro will require you to have the right syntax.


What is Visual Basic Editor?

There have been many versions of Visual Basic. It is a program which allows you to write other computer programs. Each version of Visual Basic has come with an editor to allow you to write and edit code. This is called the "IDE", or "Integrated Development Environment".


How do you create a program in visual basic?

arrays programms in visual basic


Program to print all the even numbers of an array in visual basic?

find even number in array


What is a visual basic code?

Visual Basic code is a program or library that has been written using the Microsoft Visual Basic programming language.


Why visual basic is required?

visual basic is required for program the softwares,games,calculators etc


What has the author Eric Brierley written?

Eric Brierley has written: 'Visual Basic 5 how-to' -- subject(s): BASIC (Computer program language), Microsoft Visual BASIC 'The Waite Group's Visual Basic 6 how-to' -- subject(s): BASIC (Computer program language), Microsoft Visual BASIC


Who is the inventor of visual basic program?

microsoft


Vb is extension of?

A Visual Basic program.


What are the different program structure of visual basic?

Program in visual basic are the component being used by the programer that will give the user fast and easy way.


How much math is needed to program Visual Basic?

You don't really need math to write programs in Visual Basic or most any other language unless the program is about mathematical situations. Understanding of mathematical logic concept (AND OR NOT IMPLIES) does makes thing easier.