Q
Problem solve Get help with specific problems with your technologies, process and projects.

'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.

Dig Deeper on VB 6 to VB .NET Migration

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.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

Close