The Visual Basic error 5 will be returned before the call even gets to the NI-DAQ driver if the port you are using is not a valid one.
Check the valid port numbers for your board. You can find that information in the user manual or the DAQ Hardware Overview Guide. Also, some boards have fixed directions for their ports. In this case, setting the direction is not necessary.