I changed the start of the code

Code:
@ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_OFF, MCLR_OFF,PROTECT_ON,CPD_ON, BOD_OFF, LVP_OFF
it was a part of the comments before

and changed

Code:
FOR Index = 0 TO 15   ' Scan through the bits.
to

Code:
FOR Index = 0 TO 14   ' Scan through the bits.
and the final code:

Code:
@ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_OFF, MCLR_OFF,PROTECT_ON,CPD_ON, BOD_OFF, LVP_OFF

DEFINE OSC 4

CMCON = 7
PAUSE 1
VRCON = 0
PAUSE 1

TRISA = 0
TRISB = 0
PORTA = 0
PORTB = 0
T1CON.1 = 0
OPTION_REG.5 = 0 ' Internal clk.
OPTION_REG.3 = 0 ' Prescaler assigned to TMR0.
OPTION_REG.2 = 0 ' 
OPTION_REG.1 = 0 ' 
OPTION_REG.0 = 0 ' 1:1

PAUSE 10

Led1 VAR PORTA.0    'Assign leds. 
Led2 VAR PORTA.1
Led3 VAR PORTA.2
Led4 VAR PORTA.3
Led5 VAR PORTA.4

Led6 VAR PORTB.0
Led7 VAR PORTB.1
Led8 VAR PORTB.2
Led9 VAR PORTB.3
Led10 VAR PORTB.4
Led11 VAR PORTB.5
Led12 VAR PORTB.6
Led13 VAR PORTB.7
Led14 VAR PORTA.6
Led15 VAR PORTA.7

Index VAR BYTE
LookForThree VAR BYTE
Val    VAR WORD
Result VAR BYTE
PAUSE 100


Start:


    LookForThree = 0
    WHILE LookForThree <> 3   ' Look for three "SET"s.
        RANDOM Val            ' Get a random value.
        PAUSEUS TMR0          ' To get a good random number, have a changing value using TMR0 or TMR1.
    
        LookForThree = 0
        FOR Index = 0 TO 14   ' Scan through the bits.
            IF Val.0[Index] = 1 THEN LookForThree = LookForThree + 1 'Count "SET"s.
           
            NEXT Index
    
    WEND

    GOSUB SetPins
    PAUSE 1000

    GOTO Start

SetPins:

    Led1  = Val.0
    Led2  = Val.1
    Led3  = Val.2
    Led4  = Val.3
    Led5  = Val.4
    Led6  = Val.5
    Led7  = Val.6
    Led8  = Val.7
    Led9  = Val.8
    Led10 = Val.9
    Led11 = Val.10
    Led12 = Val.11
    Led13 = Val.12
    Led14 = Val.13
    Led15 = Val.14 
    RETURN


END
it's now working good hooray! thanks for your help pips more power!