End Function Problem

retkehing

Well-known member
Joined
Feb 5, 2006
Messages
153
Programming Experience
Beginner
The following code worked fine with VB.NET 2003 and however when i made use of the same piece of code in VB.NET 2005, the End Function is underline but the whole code could be executed without any error. May i know how to get rid of the underline for good programming practise? Thank you.

VB.NET:
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] Data_Retrieval([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] emp_no_t [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]OleDbCommand1.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"SELECT * FROM Emp_Profile"[/COLOR][/SIZE]
[SIZE=2]OleDbCommand1.Connection = OleDbConnection1[/SIZE]
 
[SIZE=2]OleDbConnection1.Open()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DReader [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] OleDb.OleDbDataReader = OleDbCommand1.ExecuteReader[/SIZE]
 
 

[SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] DReader.Read[/SIZE][INDENT][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] emp_no_t = DReader([/SIZE][SIZE=2][COLOR=#800000]"emp_no"[/COLOR][/SIZE][SIZE=2]).ToString [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/INDENT][INDENT][SIZE=2][INDENT]emp_name.Text = DReader([/INDENT][/SIZE][INDENT][SIZE=2][COLOR=#800000]"emp_name"[/COLOR][/SIZE][SIZE=2]).ToString[/SIZE][/INDENT][INDENT][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][/INDENT][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/INDENT][SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
 
[SIZE=2]OleDbConnection1.Close()[/SIZE]
 
[U][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/U][SIZE=2][COLOR=#0000ff][U]Function[/U][/COLOR][/SIZE]
 
Last edited:
change the word 'Function' to 'Sub' at the top and at the bottom

your so called function isn't a function because your routine does not return anything (which is what functions are for) when a routine doesnt return anything it's a Sub therefor you declare it as a public sub instead of a public function

that's why it's underlined
 
Back
Top