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
Chat with our AI personalities
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
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
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
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.
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
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
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
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
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
Same with other Visual Basic program, programming in FoxPro will require you to have the right syntax.
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".
find even number in array
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.
First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.