Sinisterly
Need help with Codedom and making a downloader - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework)
+--- Thread: Need help with Codedom and making a downloader (/Thread-Need-help-with-Codedom-and-making-a-downloader)



Need help with Codedom and making a downloader - Jacob - 05-26-2012

Hey, I've decided to code my own little downloader in VB.NET. I'm actually having issues with this..

VS is telling me some variables are accessible and such. The variables I use are inside of an IF statement and declared at the top of the Sub.

Here are some screenshots that layout my code and the problem. I know its only a warning, but I don't really want to take the chance. Any way you think you can help?

http://gyazo.com/31d8fb572788bc398e4d5c22528c9569.png?1338078744
http://gyazo.com/473796dee8506ff472b2c61650fe52df.png?1338078798
http://gyazo.com/a3aa52e4d1550090d2e5a66bb2c4428c.png?1338079357


Here is my codedom text file source that will be compiled.
http://gyazo.com/d9523b7ccae5bf1fdbaee8e7ea48e4a7.png?1338079616


Many thanks if anyone can help me (:


RE: Need help with Codedom and making a downloader - ArkPhaze - 05-27-2012

With 'installpath' variable, you can't ensure that one of the if statement blocks are going to assign it a value, so it's still not been assigned a value since it's declaration as far as the compiler is concerned. That's why it's a warning and not an error, define it, and upon declaration give it the value of String.Empty to see.

Then before you do anything with it, if it can't be empty, then check with String.IsNullOrEmpty() and do something accordingly in that event.

Try some Case statements as well, you're cluttering your code with all these if statements and many ElseIf's. Smile