Important alert: (current site time 7/16/2013 4:02:56 AM EDT)
 

VB icon

Daily Dilbert

Email
Submitted on: 8/24/1999
By: Bjorn Larsson 
Level: Not Given
User Rating: By 109 Users
Compatibility: VB 5.0, VB 6.0
Views: 31503
 
     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!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' 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
'
' 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...
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=3201&lngWId=1'for details.'**************************************

' 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
9/7/1999 10:58:00 PMBjörn Larsson

If you're always connected to the internet, put the program in the autostart folder.. :-)
This makes the program daily.. :-)
(If this comment was disrespectful, please report it.)

 
9/9/1999 1:44:00 PMRandal

Best Program Ever!
(If this comment was disrespectful, please report it.)

 
9/13/1999 8:18:00 AMJonthan Shields

What Internet Control are you using? The Microsoft Internet Control does not seem to work.

Thanks,

Jonathan
(If this comment was disrespectful, please report it.)

 
9/13/1999 12:30:00 PMShawn Verrall

I had the same problem Jonathan did. You nned to use Microsoft Internet Transfer Control (6.0 for me)
(If this comment was disrespectful, please report it.)

 
9/15/1999 11:17:00 AMhwilliam@my-deja.com

I could not get this code to work!
I get an invalid procedureor arguement error,
on the line where nrString has it's first
assignment made.

HELP!
hwilliam@my-deja.com
(If this comment was disrespectful, please report it.)

 
9/15/1999 9:29:00 PMTax Man

Actually, it would be nice if this thing would update the windows wallpaper. If you guys want to know how to do this, MSDN has a whitepaper on changing the wallpaper at:

http://msdn.microsoft.com/library/techart/msdn_msdn192.htm

Take a look and enjoy!
(If this comment was disrespectful, please report it.)

 
9/16/1999 7:19:00 AMAkhilesh

This is good Idea, but can be improved at lot.
Well, Good Attempt.
With Best Wishes,
Akhilesh
(If this comment was disrespectful, please report it.)

 
9/20/1999 7:02:00 PMMadArse

Sounds cool, but which component has the Internet Control? Im using VB5 sp3

(If this comment was disrespectful, please report it.)

 
9/27/1999 9:00:00 PMEM Dixson

A nice try but I have tried the MS Internet Control and t doesn't fly. Sorry guy.
VISIT MY SITE: http://developer.ecorp.net
FREE Visual Basic Source Code
(If this comment was disrespectful, please report it.)

 
10/2/1999 2:41:00 PMzaid

guys i tried this and after executing my program 2 or three times i get some system error saying "System Error. Call not colintialized" any can help me please???
thnks
(If this comment was disrespectful, please report it.)

 
10/12/1999 2:56:00 PMkennyle

Great Program
I have a question
What are other datatypes for inet control
beside icByteArray?
(If this comment was disrespectful, please report it.)

 
10/20/1999 9:23:00 AMScott Hutchinson

It worked great. I modified it to use the SetTimer API so it automatically refreshes ever 12 hours. Unfortunately, I don't have a way to turn it off (except using the Task Manager to kill the process). Other than giving it its own systray icon, I'm not sure how else to do it. Unless I could make it an NT service?
(If this comment was disrespectful, please report it.)

 
10/25/1999 7:39:00 AMRoad Dogg

This works great, exept when i make it an .exe and run it I get a "The memory could not be read", this is probly becuse i use this program on an NT workstation, does anybody know what changes have to be made to avoid this error on an nt workstation.
(If this comment was disrespectful, please report it.)

 
10/28/1999 5:14:00 PMTom Williams

This is a pretty need demonstration and it works great on Win95 and Win98. However, the SystemParametersInfo() API call does not effect Windows NT.

Does anyone know how to get around this. If have done a search on MSDN and have not located any other functions for NT.

Thanks in advance.
(If this comment was disrespectful, please report it.)

 
10/28/1999 6:55:00 PMTom Williams

I also found that this code will blow up the first time that you use it. It is like it doen't recognize that the new Dilber.Gif exists in the hard drive. However, once you have the first file on your hard drive it works pretty good.

On NT though I found that you can get the image to show. You have to get the properties for your Desktop and then close it out. It is like the picture has been set for your desktop but the screen just has not been updated. F5 doesn't even do it.

If someone has a workaround let me know.
(If this comment was disrespectful, please report it.)

 
10/28/1999 8:12:00 PMTom Williams

Ok Last Time...

When I close the Application on an NT system I get a Doctor Watson error stating; Could not attach to the application, Windows NT Error Code=87.

What's up with that????
(If this comment was disrespectful, please report it.)

 
11/23/1999 12:32:00 PMThorsten

Excellent code... I was wondering, how would you take this code and apply it to a page that has a gif image on it but the image is not archived. The image is reproduced by an external program. Email me if you need more info.

Thanks
(If this comment was disrespectful, please report it.)

 
12/19/1999 9:21:50 PMMouse

THANKS!!! this werks GREAT!!!!
you have made my life just that much easier! keep up the great werk!!!!
(If this comment was disrespectful, please report it.)

 
1/12/2000 4:36:21 PMZaid

hi there,

the wallpaper thingy does'nt work for winNT. any solutions???
(If this comment was disrespectful, please report it.)

 
1/16/2000 11:22:44 PMLNZ

This Kode Roques, Keep ^ the good WERK.
(If this comment was disrespectful, please report it.)

 
4/25/2000 7:15:30 PMBenii

When I try to run it it give a pop up window that says "Compiler error: invalid outside procedure" and highlights "http://www.unitedmedia.com/comics/dilbert/archive/" from Text1.Text = Inet1.OpenURL("http://www.unitedmedia.com/comics/dilbert/archive/") Does anyone know how I could fix this?
(If this comment was disrespectful, please report it.)

 
11/8/2000 10:32:29 AMSteven Denman

I have VB 6.0 and have loaded the inet transfer control. Although it doesn't set the text box (stays blank) so the prog gets baffed. any ideas ? thx

denmsd94@christs-hospital.org.uk
(If this comment was disrespectful, please report it.)

 
11/21/2000 3:06:56 PMv0doo600

How exactly do i make this work?
as soon as i compile the program
and iopen it the thing hides or something.
(If this comment was disrespectful, please report it.)

 
11/21/2000 3:10:38 PMv0doo600

in other words the file will get saved to my drive C:
but it wont make my background the comic
(If this comment was disrespectful, please report it.)

 
1/1/2003 3:26:03 AM

i keep trying this program and it doesnt seem to want to work. it keeps giving me "Inet1, variable not defined."
maybe it's just me, but i don't know how to get past this, i have Microsoft Internet Transfer Controls 6.0 enabled.

please help a newbie in need :( :( :(
(If this comment was disrespectful, please report it.)

 

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.