how to...

whosyodaddy

Regular
Joined
Jun 23, 2003
Messages
83
ok, I am making a simple program, which is basically has new info everyday. What I am saying is, everyday when you run it, different stuff will appear. Sort of like a news-tracker. What I want is the user to open it and, lets say, a certain image appears (although the image is not built in the program, so It will have to be updated everyday automatically) and i choose the image. how would i go about doing this? It is quite a large question. I've read some books, and still, have no clue how to do this. Thanks. :D
 
Where are you getting the info or images from?

If you use a database for the info, you can easily randomize which item to display.
 
Is this info. going to be transmitted over to the web? I assume it is since you mentioned something about a news tracker (or did you mean news ticker?).

Try using a database + web services.
 
i want it so that i can choose what image they see and what text they see daily. whenever they run the program, yea, transmitted over web...
 
Last edited:
from the net , here's an example of putting >> :D << in to a picturebox. you can specify your url's as you want in there.
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim stream As New Net.WebClient()
        Dim sr As IO.Stream = stream.OpenRead("http://www.xtremedotnettalk.com/images/smilies/biggrin.gif")
        PictureBox1.Image = Image.FromStream(sr)
        sr.Close()
    End Sub
 
If you want to change the URL to the image you could make a simple web service to retrieve the URL or path to the file, or have the program setup to download a small text file which will contain the URL to the image.
 
Awesome, but how would you check if the person has an open internet connection?

Would you use Try and Catch? And then if there is an error, just close the program?
 
That would the easiest way, set up a Try...Catch block around the line that download the file and catch the WebException exception. Or, use InternetGetConnectedState API.
 
Last edited:
If you dont want to create a web service then go with the file approach.
Try...Catch is an error handling structure. You set it up like this:
Visual Basic:
Try
    'code that can cause errors here
Catch ex As WebException 'or any other exception you might want
    'handle the error or simple do nothing
End Try
 
Back
Top