3 Questions from a beginner

ricky92

Member
Joined
Jan 13, 2007
Messages
13
Location
Naples, Italy
Programming Experience
Beginner
Hello, I'm new. I'm coding my first 2 applications, a simple webbrowser and a site sponsor links doer. First of all, how can I set the statusbar so it views the current download status of the page in the browser? then another 2 questions about the other program. How can I save login Info in a cookie/file/whatever I can use to remember it??? I'm very beginner and a complete guide would be really helpful. Finally, a simple question. How can I navigate to a page without the webbrowser control? I mean without an interface, just go to the link (logged in as a user using a wrapper), then wait and go to another link!!!

Sorry for my English, I'm 14 years old and I'm not English. If you need help understanding me, just ask. I know my English is terrible!!!
 
1. The WebBrowser class has a ProgressChanged event. You handle that event and use the e.CurrentProgress and e.MaximumProgress property values.

2. You wouldn't use a cookie because your app isn't a Web page itself. You can save data for your app anywhere you like. It could be in text files, application settings, a database, etc. It's really up to you.

3. You can use a WebClient object in some simple situations or an HttpWebRequest for more fine-grained control.
 
Thanks for answering my questions!!! Only two things, as I'm a idiot and don't understand how to use them: How can I save the Username and the Password in the txtUser.Text and in the txtPass.Text to a text file so the program automatically loads it everytime it starts??? And where do I put things so the changes happens without a click or anything? In a BackgroundWorker???
 
The simplest way to save a text file is with IO.File.WriteAllText, but in that case you have to have all the text to write as a single string. Alternatively you could have multiple lines of text ina string array and use IO.File.WriteAllLines. If that's no good either then you would create a StreamWriter object and call its Write or WriteLine methods. The converse are the ReadAllText, ReadAllLines methods and the StreamReader class.
 
I like to use the My.Settings variables for keeping some of this. Go to the project properties and click the settings tab. There you can enter the names of new variables that your app will keep even when it is restarted. Then to use it, you just do this.
VB.NET:
My.Settings.mypassword = Textbox1.Text
 
Ehy thanks for the help!!! Ehm... sorry for bothering, but I can't understand the progressbar. I dunno how to get the value...:eek:

VB.NET:
    Private Sub WebBrowser_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles WebBrowser.ProgressChanged 'Whoops!!! Error!
        stbPanelText.Value = 'What do I put here???
    End Sub
I know nothing... :(
 
CurrentProgress may for example be 123 and MaximumProgress may be 1230, that is 10%. Both these values changes all the time.
 
VB.NET:
Dim progressString As String = String.Format("current progress is {0} of current maximum {1}", e.CurrentProgress.ToString, e.MaximumProgress.Tostring)
 
I mean a code example, cause I tryed it but it tells me ther's an error. I think I should add some brackets, but I dunno what!!!
If you try something and it doesn't work then post the code and details of what happens and where.

Note that both those values are just numbers, so to use them you're just performing simple mathematics. If you would need to use parentheses in a simple mathematical statement to perform the same calculation then you need them in your code. Otherwise you don't.
 
Back
Top