Click here to Skip to main content
15,881,380 members

Comments by 0x3c0 (Top 6 by date)

0x3c0 24-Oct-10 10:45am View    
Please edit your additions into the main question - it makes it easier to locate. As for your question - pass the return value to mciGetErrorString.
For what it's worth, mciSendString returns an integer, not a long. Your value is going to be odd. Fix this first.
0x3c0 13-Jul-10 8:43am View    
Please post your responses as on the answer you're replying to. You find out where it's faulting by stepping through it, and finding the part of your code which executed just before the fault occurred.
0x3c0 12-Jun-10 9:06am View    
Thank you for your question; I've put your code in a code block so it's easier for other members to read
0x3c0 12-Jun-10 4:44am View    
You're welcome. I suspect that the error comes from the last concatenation of the line variable. At that point, line is Nothing, so it may simply be that you get a NullReferenceException. There are also a few pieces of redundant code - when you close the StreamReader, the underlying Stream is also closed. Beyond that, the stream is closed when it gets Dispose called, as your Using block will do. It won't cause any massive errors, but it's a little inefficient.

A slightly better loop, and one which is less likely to cause an error is:
line = sr.ReadLine()
Do While line IsNot Nothing
strCreds = strCreds & line ' If you wanted better performance and more efficient memory usage, you could use a StringBuilder's Append method
line = sr.ReadLine()
Loop
0x3c0 11-Jun-10 17:07pm View    
Yes, you're pretty much there. You've got the response stream, now you just need to (I assume you still want to manipulate text) create a System.IO.StreamReader, passing responseStream to the constructor. Then, you can use ReadLine and the associated methods just like you would a normal file