what about this then?
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)
$o = $o+($=" ") -$o*($=!|$='?'|$='.')
$r = instr($p,$)
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
KiXtart
KiXtart Version = KiXtart 2001 4.22 Release Candidate 1
KiXforms Version =
KiXGolf Script = kixgolf_vigenere.kix
Computer
OS = Windows 2000 Professional
CPU = Intel Pentium II
Speed = 398 MHz
Memory = 384 MB
KiXGolf Scoring Engine
Scoring Engine = 3.0.3
KiXtart Golf Score
Tournament = KiXtart Golf: Vigenere Cipher
Valid Cipher Ops = 7 (64%)
Processing Start = 2004/08/04 15:31:23.896
Processing End = 2004/08/04 15:31:24.246
Duration = 0000/00/00 00:00:00.349
KiXGolf Score = 366
Thank you for participating in KiXtart Golf!