Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Converting VB.net 2005 to VB 2010 question

Posted on 2010-08-19
7
Medium Priority
?
807 Views
Last Modified: 2013-11-27
I opened a VB 2005 project with Vb 2010 version. A questioned pop up saying this project will be save under Vb 2010 format. I notices however , received  30 warnings.. all the functions in the class I build displayed in the error list with a common message..
"Function without an 'As' clause; return type of Object assumed."

What should I do to avoid this message? Also it displays a curly line on the function name?
Is this an issue with Vb 2010 when trying to convert a Vb 2005 project?
0
Comment
Question by:zachvaldez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 33480167
a function should return something. the As clause is used to determine the datatype of that something.
to fix it:
1. Add the as clause
2. convert your Function to Sub
You have this error because VS2010 is more strict on the syntax
0
 
LVL 17

Accepted Solution

by:
Zhaolai earned 1000 total points
ID: 33480193
Every function has a return type and value. Apparently VB 2010 is more explicit, but still it's just a warning.

If it's annoying, you can add the explicit return type to all those function.

Function foo() as Integer
    Dim iFoo as integer
    ....
    Return iFoo
End Function
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 33480375
it is a bad coding ;)
if you have a function you should tell what the return type is...
if you do not tell what is the return type than an object is returned from that function

function mySum (a as int, b as int) as int
begin
  return a+b
end

then when you call mySum(3,5) an object will be returned not an int and you need to convert it to int again...
to prevent all those, add "as return_type" to all your functions
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 33481305
A function should always return a value, And a Sub does not return a value...
So, in practice if a routine must return a result you use Function otherwise Sub.
0
 

Author Comment

by:zachvaldez
ID: 33485065
my functions are basically populating data so I should probably identify them as 'SQLDatareader or dataset..
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 33485553
can you show one of your method?
can you show how you call it?
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 33489147
what are you returning in these functions?

Return something

then use

function myFunction(...) as type_of_something

if you do not return anything then they should be converted into sub

sub mySub(...)
begin
...
end sub
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question