391 with correct word shift.
Code:

Function vigenere($t,$k,optional $d)
DIM $j,$r,$,$p,$o,$y

For $j=65 To 90
$=CHR($j)+$+CHR($j+32)
Next
$p="0123456789"+$

For $j=1 To Len($t)
Do
$=Left($k,1)
$k=Right($k,-1)+$
$y=InSTR($p,$)
Until $y

$=SubSTR($t,$j,1)
$r=InSTR($p,$)
$o=IIf(0<InSTR('! ? . ',$+SubSTR($t,$j+1,1)),-1,$o+($=' '))

If $r
$=62-(UCase($t+$k)=$t+$k)*26
$=SubSTR($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1)
EndIf

$vigenere=$vigenere + $
Next

EndFunction

_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...