Getox Posted October 3, 2004 Posted October 3, 2004 i want to set the textbox text to what is in a file so far i have Dim oFile As System.IO.File Dim oRead As System.IO.StreamReader oRead = oFile.OpenText("settings.ini") Me.homepage.Text(oRead) but "Me.homepage.Text(oRead)" is wrong, can anyone help? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
*Experts* mutant Posted October 3, 2004 *Experts* Posted October 3, 2004 This depends on how much of the file you want to read. If you want to read the whole file then use the StreamReader's ReadToEnd() method, if you want a line then use the ReadLine() method, etc. If you are using INI files, you might want to take a look at this useful set of classes for working with INI files: http://www.codeproject.com/vb/net/VbNetClassIniFile.asp Quote
Getox Posted October 4, 2004 Author Posted October 4, 2004 well all that is in settings.ini is just a url to a site Settings.ini: http://www.trelio.com/ all i want to do is just make the text box show the contents of the settings.ini file Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Getox Posted October 4, 2004 Author Posted October 4, 2004 well i tried a diff way but it still dont work Dim oFile As System.IO.File Dim oRead As System.IO.StreamReader oRead = oFile.OpenText("settings.ini") homepage.AppendText(oRead) oRead.Close() "Form4.vb(86): Value of type 'System.IO.StreamReader' cannot be converted to 'String'." that line is "homepage.AppendText(oRead)" Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Administrators PlausiblyDamp Posted October 4, 2004 Administrators Posted October 4, 2004 Did you try Mutant's suggestion? You cannot simply use a StreamReader instead of a string - you need to call one of it's Methods to read from the file. Assuming homepage is a textbox try Dim oFile As System.IO.File Dim oRead As System.IO.StreamReader oRead = oFile.OpenText("settings.ini") homepage..Text= oRead.ReadToEnd() oRead.Close() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Getox Posted October 4, 2004 Author Posted October 4, 2004 Did you try Mutant's suggestion? You cannot simply use a StreamReader instead of a string - you need to call one of it's Methods to read from the file. Assuming homepage is a textbox try Dim oFile As System.IO.File Dim oRead As System.IO.StreamReader oRead = oFile.OpenText("settings.ini") homepage..Text= oRead.ReadToEnd() oRead.Close() Hey thanks that got it working :) how would i make it just read the top line? or XX line ? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Getox Posted October 5, 2004 Author Posted October 5, 2004 Check out the #2! i would if i knew the readline stuff but im new to .net! http://www.trelio.com/readline.JPG Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Administrators PlausiblyDamp Posted October 5, 2004 Administrators Posted October 5, 2004 Did you even consider cheking MSDN or even the tooltips (or possibly the error message)? ReadLine doesn't take any parameters - it simply reads the next line from the file. homepage..Text= oRead.ReadLine() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.