You probably need to create a new STREAM object first (using the STRING pathname). I’m not VB oriented, but that would be my initial guess. What does Intellisense say about the StreamReader’s argument types?
From: [email protected] <[email protected]> On Behalf Of [email protected] Sent: Monday, November 25, 2019 11:53 AM To: [email protected] Subject: [nlug] [OT] Visual Basic Question I am trying to code a Visual Basic 2019 console app that makes use of the StreamReader object to read text from a file. According to the Microsoft documentation for the StreamReader object, when it is initialized, you pass a string with the path of the file to be opened, such as Using reader as StreamReader = new StreamReader(“c:\sample.txt”) However, all of the Microsoft documentation has the path hard-coded, not as a variable. In my code, I am declaring a variable as type string, calculating its value at runtime, and passing that string to StreamReader as an argument. Dim thisFile as string Using reader as StreamReader = new StreamReader(thisFile) This results in a compile-time error, BC30311 Value of type ‘String’ cannot be converted to ‘Stream’ What data type do I need to declare the variable as, instead of as a string, for this to compile and work? -- This message has been scanned for viruses and dangerous content by <http://www.efa-project.org> E.F.A. Project, and is believed to be clean. Click here to report this message as spam. <http://jsefagate.jobsoft.com/cgi-bin/learn-msg.cgi?id=172CF160812.AAB0C&token=96656b46d9b063c455fa1582db136a25> -- -- You received this message because you are subscribed to the Google Groups "NLUG" group. To post to this group, send email to [email protected] <mailto:[email protected]> To unsubscribe from this group, send email to [email protected] <mailto:[email protected]> For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en --- You received this message because you are subscribed to the Google Groups "NLUG" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]> . To view this discussion on the web visit https://groups.google.com/d/msgid/nlug-talk/002f01d5a3b9%24257ec580%24707c5080%24%40jfeldredge.com <https://groups.google.com/d/msgid/nlug-talk/002f01d5a3b9%24257ec580%24707c5080%24%40jfeldredge.com?utm_medium=email&utm_source=footer> . -- -- You received this message because you are subscribed to the Google Groups "NLUG" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en --- You received this message because you are subscribed to the Google Groups "NLUG" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nlug-talk/016401d5a3b9%24c196a410%2444c3ec30%24%40jobsoft.com.
