VB icon

Daily Dilbert

Email
Submitted on: 1/3/2015 5:21:00 AM
By: Bjorn Larsson (from psc cd)  
Level: Not Given
User Rating: By 109 Users
Compatibility: VB 5.0, VB 6.0
Views: 2288
 
     This program Downloads the archive page from ' http://www.unitedmedia.com/comics/dilbert ' extracts the file name of the picture. Download it. Convert it to bitmap. ' Changes the desktop wallpaper to the new dilbert strip.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Daily Dilbert
'**************************************
Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Daily Dilbert
' Description:This program Downloads the archive page from 
' http://www.unitedmedia.com/comics/dilbert 
' extracts the file name of the picture. Download it. Convert it to bitmap. 
' Changes the desktop wallpaper to the new dilbert strip.
' By: Bjorn Larsson (from psc cd)
'
' Returns:2 files on c:\ dilbert.gif and dilbert.bmp
' A changed wallpaper.
'
' Assumes:You must have an internet connection..
'
' Side Effects:Sometimes the desktop wallpaper is not visible 
' unless you refresh the desktop yourself 
' or select it manually. I don't know why this happends...
'**************************************

' 1. Create a new form.
' 2. Add a Textbox,a pictureBox and an Inet control.
' 3. Let them all have their default name. 
' 4. Put all the code expect the global decleration in the "form load procedure"
 Dim Pos As Integer
 Dim Pos2 As Integer
 Dim Bilden() As Byte
 Dim NrString As String
 Text1.Text = Inet1.OpenURL ("http://www.unitedmedia.com/comics/dilbert/archive/") 'Download the page.
 Pos = InStr(1, Text1.Text, "/comics/dilbert/archive/images/dilbert")
 Pos2 = InStr(Pos, Text1.Text, ".gif")
 NrString = Mid(Text1.Text, Pos, Pos2 - Pos)
 Text1.Text = "http://www.unitedmedia.com" + NrString + ".gif" ' Debug filename
 Bilden() = Inet1.OpenURL("http://www.unitedmedia.com" + NrString + ".gif", icByteArray) ' Download picture.
 Open "C:\dilbert.gif" For Binary Access Write As #1 ' Save the file.
 Put #1, , Bilden() 
 Close #1 
 Picture1.Picture = LoadPicture("c:\dilbert.gif") 'Reload it to PictureBox
 SavePicture Picture1.Picture, "c:\dilbert.bmp"'Converted to bmp.. 
 
 Call SystemParametersInfo(20, 0, "c:\dilbert.bmp", 1) 'Change the wallpaper.
 Unload Me ' Exit program


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.