[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? -- -- 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.
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 On Behalf Of j...@jfeldredge.com Sent: Monday, November 25, 2019 11:53 AM To: 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 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/016401d5a3b9%24c196a410%2444c3ec30%24%40jobsoft.com.
RE: [nlug] [OT] Visual Basic Question
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 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> 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.
RE: [nlug] [OT] Visual Basic Question
That is a bit odd, but then again, M$ VS. I wonder, though, unless it’s overloaded (STRING being one of them), it would sort of make sense to me as I normally thing of a STREAM being one of several source input types. Of course, VS has never been known to be buggy or lacking in Intellisense! :) The error sounds like when you have a type that can’t be automatically casted. I know in C# there is ‘string’ and there is ‘String’, and while they both more or less represent the same thing, they are distinctly different object types. Go figure! From: nlug-talk@googlegroups.com On Behalf Of j...@jfeldredge.com Sent: Monday, November 25, 2019 12:02 PM To: nlug-talk@googlegroups.com Subject: RE: [nlug] [OT] Visual Basic Question 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 <mailto:nlug-talk@googlegroups.com> mailto:nlug-talk@googlegroups.com> > On Behalf Of Mark J. Bailey Sent: Monday, November 25, 2019 11:57 AM To: nlug-talk@googlegroups.com <mailto: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> 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
Re: [nlug] [OT] Visual Basic Question
Instead of passing a string, try: new FileStream(fileName, FileMode.Open), Encoding.UTF8) On Mon, Nov 25, 2019 at 12:10 PM Mark J. Bailey wrote: > That is a bit odd, but then again, M$ VS. I wonder, though, unless it’s > overloaded (STRING being one of them), it would sort of make sense to me as > I normally thing of a STREAM being one of several source input types. Of > course, VS has never been known to be buggy or lacking in Intellisense! :) > The error sounds like when you have a type that can’t be automatically > casted. I know in C# there is ‘string’ and there is ‘String’, and while > they both more or less represent the same thing, they are distinctly > different object types. Go figure! > > > > *From:* nlug-talk@googlegroups.com *On > Behalf Of *j...@jfeldredge.com > *Sent:* Monday, November 25, 2019 12:02 PM > *To:* nlug-talk@googlegroups.com > *Subject:* RE: [nlug] [OT] Visual Basic Question > > > > 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 *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 *On > Behalf Of *j...@jfeldredge.com > *Sent:* Monday, November 25, 2019 11:53 AM > *To:* 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 > *E.F.A. Project* <http://www.efa-project.org>, 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 > 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 > <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 > 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...@googlegro
Re: [nlug] [OT] Visual Basic Question
My guess would be that because you're not explicitly providing a class name for the function, the compiler is "guessing" the wrong class. So, instead, you might want to tell it explicitly which function you want, i.e. instead of: Using reader as StreamReader = new StreamReader(thisFile) try Using reader as StreamReader = new My.Computer.FileSystem.StreamReader(thisFile) On Mon, Nov 25, 2019 at 11:52 AM wrote: > > 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. -- Tilghman -- -- 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/CAHPkZcVGaPygNepU4gP0tz4J%3DxwjxzdGd__e9S93SJRMpZqF3g%40mail.gmail.com.
RE: [nlug] [OT] Visual Basic Question
OK, I found a work-around. I have to use an additional, undocumented step. Using fs As FileStream = New FileStream(thisFile, FileMode.Open) Using reader As StreamReader = New StreamReader(fs) fileText = reader.ReadLine() End Using End Using I found examples of code online that used my earlier approach, so I am guessing that the need to wrap the file into a FileStream is new, and Microsoft hasn’t bothered to update the documentation, since all of their examples are using hard-coded file paths, not variables. The “Using” statements are a way to make Visual Basic handle the garbage collection once the objects are no longer in scope. From: nlug-talk@googlegroups.com On Behalf Of j...@jfeldredge.com Sent: Monday, November 25, 2019 11:53 AM To: 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? -- -- 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 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/00a901d5a3c5%244855e050%24d901a0f0%24%40jfeldredge.com.
RE: [nlug] [OT] Visual Basic Question
Good deal! I’ve found that devops forum sites like Stack Exchange, Stack Overflow, CodeWorks, Quora and Spiceworks always seem to do more for me than most “official” MSDN .Net/Class “documentation”! :) I sometimes think the tech writers for M$ are, for the most part, really only writing for each other! :) From: nlug-talk@googlegroups.com On Behalf Of j...@jfeldredge.com Sent: Monday, November 25, 2019 1:20 PM To: nlug-talk@googlegroups.com Subject: RE: [nlug] [OT] Visual Basic Question OK, I found a work-around. I have to use an additional, undocumented step. Using fs As FileStream = New FileStream(thisFile, FileMode.Open) Using reader As StreamReader = New StreamReader(fs) fileText = reader.ReadLine() End Using End Using I found examples of code online that used my earlier approach, so I am guessing that the need to wrap the file into a FileStream is new, and Microsoft hasn’t bothered to update the documentation, since all of their examples are using hard-coded file paths, not variables. The “Using” statements are a way to make Visual Basic handle the garbage collection once the objects are no longer in scope. From: nlug-talk@googlegroups.com <mailto: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? -- -- 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/00a901d5a3c5%244855e050%24d901a0f0%24%40jfeldredge.com <https://groups.google.com/d/msgid/nlug-talk/00a901d5a3c5%244855e050%24d901a0f0%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 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 t