help in code plz

Tahmid

Joined Jul 2, 2008
343
Hi again,
Here's a sample code in VB6:

Rich (BB code):
Dim firstno As Integer
Dim secondno As Integer
Dim lastno As Integer
Dim loopno As Integer

Private Sub Command1_Click()
    On Error GoTo ErrH
    Me.Cls              'Clear form before printing anything
    firstno = 1         'This is the number with which the series starts, dont
                           'change
    secondno = 1     'This is the number following, dont change
    lastno = 22        'This is the last number to which to calculate the
                           '     series. This is going to be greater than the last no.
                           '     Change as desired
    Print 0
    Print firstno
    Print secondno
    Do
        loopno = secondno
        secondno = firstno + secondno
        If secondno < lastno Then
            firstno = loopno
            Print secondno
        End If
    Loop Until secondno > lastno
ErrH: 'In case there is some error in the loop
End Sub
Hope this clears things up.
 

Attachments

Top