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?

-- 
-- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To post to this group, send email to nlug-talk@googlegroups.com
To unsubscribe from this group, send email to 
nlug-talk+unsubscr...@googlegroups.com
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 nlug-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nlug-talk/002f01d5a3b9%24257ec580%24707c5080%24%40jfeldredge.com.

Reply via email to