Type Mismatch

Hello,

Dans une fonction, j'ai la condition suivante pour laquelle chaque variable est de type Long :

If (a_converted >= Start_work & a_converted <= End_work) & (b_converted >= Start_work & b_converted <= End_work) Then

Cependant j'ai un message d'erreur de type Type Mismatch. Quelque chose de louche dans cette ligne ?

Merci bien.

Je rajoute ça :

    Dim a_converted, b_converted, a_hours, a_minutes, a_seconds, b_hours, b_minutes, b_seconds As Long
    Dim Rest_time, Start_work, End_work, Evening_rest, Morning_rest, Midnight As Long

    d = DateDiff("d", a, b)

        'Correcting factors with schedule from 09:00 to 18:00.

        a_hours = Hour(a)
        a_minutes = Minute(a)
        a_seconds = Second(a)
        a_converted = a_hours * 3600 + a_minutes * 60 + a_seconds

        b_hours = Hour(b)
        b_minutes = Minute(b)
        b_seconds = Second(b)
        b_converted = b_hours * 3600 + b_minutes * 60 + b_seconds

        Rest_time = 54000       'Rest time of 15 hours = 54000 secs.
        Start_work = 32400      '9 hours converted in seconds.
        End_work = 64800        '18 hours converted in seconds.
        Evening_rest = 21600    'Time from 18 hours to 24 hours.
        Morning_rest = 32400    'Time from 00 hours to 9 hours.
        Midnight = 86400        'Midnight o'clock.

        Factor = 0
        Factor_a = 0
        Factor_b = 0

        If (a_converted >= Start_work & a_converted <= End_work) & (b_converted >= Start_work & b_converted <= End_work) Then
            Factor = d

Bonjour,

& est un opérateur de concaténation, ce n'est pas un AND.

chaque variable est de type Long

non. Seulement la dernière de chaque ligne. Il faut les typer toutes individuellement.

Pourquoi avoir enlevé la ligne Function ?

Dis plutôt ce que tu veux faire, j'ai l'impression que ça peut s'écrire en 3-4 lignes.

eric

Merci !!!

Rechercher des sujets similaires à "type mismatch"