[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 817
  • Last Modified:

Converting VB.net 2005 to VB 2010 question

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
zachvaldez
Asked:
zachvaldez
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
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
 
ZhaolaiCommented:
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
 
HainKurtSr. System AnalystCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
PagodNaUtakCommented:
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
 
zachvaldezAuthor Commented:
my functions are basically populating data so I should probably identify them as 'SQLDatareader or dataset..
0
 
Éric MoreauSenior .Net ConsultantCommented:
can you show one of your method?
can you show how you call it?
0
 
HainKurtSr. System AnalystCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now