Q

'As Any' is not working in my .NET code like it did in VB6

In VB6, I used the following code to change the desktop wallpaper:

Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1

Private 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

Public Sub SetWallpaper(ByVal FileName As String)
  Dim ret As Long
  ret = SystemParametersInfo(SPI_SETDESKWALLPAPER,_ 
  0&, FileName, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
End Sub

In .NET, you can't use the "As Any" on the function declaration. I changed it to "As String" and tried the same code. While it works in VB6, it does not work in .NET. What am I doing wrong?
You need to change the 'As Any' statement to be more specific. Changing it to 'As Long' should work just fine.

This was first published in June 2003

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close