Still looking at it, the CreateVertexBuffer is returning the D3D error 'invalid params' so I'm not sure it is actually being created and thats why you get the crash when you try and lock it.
Global result:Int result=9999 result=primarydevice.d3d.CreateVertexBuffer(desc,d3dVertexBuffer,Null) Print "result from Create Buffer="+result 'should be 0 for D3D_OK