Intellisense says to use a string argument. My guess is that I have run into a 
managed-code vs. unmanaged-code issue, and that a literal argument is being 
silently cast to the proper managed-code string type, but I haven’t found any 
documentation saying how to declare a managed-code string.

 

From: nlug-talk@googlegroups.com <nlug-talk@googlegroups.com> On Behalf Of Mark 
J. Bailey
Sent: Monday, November 25, 2019 11:57 AM
To: nlug-talk@googlegroups.com
Subject: RE: [nlug] [OT] Visual Basic Question

 

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: nlug-talk@googlegroups.com <mailto:nlug-talk@googlegroups.com>  
<nlug-talk@googlegroups.com <mailto:nlug-talk@googlegroups.com> > On Behalf Of 
j...@jfeldredge.com <mailto:j...@jfeldredge.com> 
Sent: Monday, November 25, 2019 11:53 AM
To: nlug-talk@googlegroups.com <mailto:nlug-talk@googlegroups.com> 
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 nlug-talk@googlegroups.com 
<mailto:nlug-talk@googlegroups.com> 
To unsubscribe from this group, send email to 
nlug-talk+unsubscr...@googlegroups.com 
<mailto: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 
<mailto: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
 
<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 nlug-talk@googlegroups.com 
<mailto:nlug-talk@googlegroups.com> 
To unsubscribe from this group, send email to 
nlug-talk+unsubscr...@googlegroups.com 
<mailto: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 
<mailto:nlug-talk+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nlug-talk/016401d5a3b9%24c196a410%2444c3ec30%24%40jobsoft.com
 
<https://groups.google.com/d/msgid/nlug-talk/016401d5a3b9%24c196a410%2444c3ec30%24%40jobsoft.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 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/004201d5a3ba%247e52d560%247af88020%24%40jfeldredge.com.

Reply via email to