2 functions & a serial port (HELP?)

hello all, i am using vb 2005 to create a program which allows my robot leg to move up (walk0) n fwd(walk1). except my code only executes walk1 n not walk0. wat i have done here is to call walk0 n walk1 in a sub function called walking() with walk 0 called 1st followed by a sleep n then walk1 n another sleep. values of walk0 n walk1 are to passed up to variable d n then to be write out by serial port one function after another. however, wat i have here is dat only walk1 is being passed up to d. how can i pass up walk0 to d n write it b4 returning back to my sub fx walking() and passing up walk1 to d n write it? n then of coz close the serial port. i need help. any ideas?

PrivateSub StartWalking_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Walk.Click

Dim aAsString

Dim bAsInteger

Dim cAsString

Dim dAsString

Dim iAsInteger = 1

a = &HFF

b = &H5F

c = &H11

Call Walking(i)

d = (SendWalk(0)Xor SendWalk(1)Xor SendWalk(2)Xor SendWalk(3)Xor SendWalk(4)Xor SendWalk(5)Xor SendWalk(6)Xor SendWalk(7)Xor SendWalk(8)Xor SendWalk(9)Xor SendWalk(10)Xor SendWalk(11)Xor SendWalk(12)Xor SendWalk(13)Xor SendWalk(14)Xor SendWalk(15)Xor SendWalk(16))And &H7F

Dim allAsByte() = {a, b, c, SendWalk(0), SendWalk(1), SendWalk(2), SendWalk(3), SendWalk(4), SendWalk(5), SendWalk(6), SendWalk(7), SendWalk(8), SendWalk(9), SendWalk(10), SendWalk(11), SendWalk(12), SendWalk(13), SendWalk(14), SendWalk(15), SendWalk(16), d}

SerialPort1.Open()

SerialPort1.Write(all, 0, 21)

SerialPort1.Close()

EndSub

PrivateSub Walking(ByVal iAsInteger)

Call Walk0(i)

Threading.Thread.Sleep(2000)

Call Walk1(i)

Threading.Thread.Sleep(2000)

i = i + 1

EndSub

PrivateFunction Walk0(ByVal iAsInteger)'RLeg_Up

SendWalk(0) = &H69

SendWalk(1) = &H5

SendWalk(2) = &HB8

SendWalk(3) = &H10

SendWalk(4) = &H9B

SendWalk(5) = &HDC

SendWalk(6) = &H3D

SendWalk(7) = &H87

SendWalk(8) = &HB9

SendWalk(9) = &HFE

SendWalk(10) = &H4F

SendWalk(11) = &HAF

SendWalk(12) = &HC3

SendWalk(13) = &HD7

SendWalk(14) = &HB4

SendWalk(15) = &H75

SendWalk(16) = &H7C

Return SendWalk

Application.DoEvents()

EndFunction

PrivateFunction Walk1(ByVal iAsInteger)'RLeg_Down

SendWalk(0) = &H5F

SendWalk(1) = &H5

SendWalk(2) = &HB9

SendWalk(3) = &HF

SendWalk(4) = &H9C

SendWalk(5) = &HDC

SendWalk(6) = &H3D

SendWalk(7) = &H88

SendWalk(8) = &HA5

SendWalk(9) = &HFB

SendWalk(10) = &H48

SendWalk(11) = &HAD

SendWalk(12) = &HC4

SendWalk(13) = &HD7

SendWalk(14) = &HC4

SendWalk(15) = &H75

SendWalk(16) = &H7C

Return SendWalk

Application.DoEvents()

EndFunction

[7180 byte] By [sabmni745] at [2007-12-27]