没有As子句的函数 [英] function without an As clause

查看:62
本文介绍了没有As子句的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在aspx页面中使用函数,如下所示.

Aspx代码
----------

Hi,

I am using function in aspx page as below.

Aspx Code
----------

<td align="center" title="<%=RdrDesign(" designation=")%>"> <%= FindVal(RdrEmp("Emp_number"), RdrDesign("DesigCode"))%></td>




aspx.vb代码
-------------




aspx.vb code
-------------

Private Function FindVal(ByVal ID, ByVal Desig)
        Dim Conn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("MPP").ConnectionString)
        Dim Cmd As New System.Data.SqlClient.SqlCommand
        Dim RdrCatVal As System.Data.SqlClient.SqlDataReader
        Dim StrQry As String
        Dim CatVal As Integer
        StrQry = "Select isnull(" & Desig & ",''N'') from csEmpCategory where emp_number =''" & ID & "'' "
        Cmd.Connection = Conn
        Cmd.CommandText = StrQry
        RdrCatVal = Cmd.ExecuteReader
        If RdrCatVal.HasRows Then
            While RdrCatVal.Read
                CatVal = RdrCatVal(0)
            End While
            FindVal = CatVal
        End If
    End Function



我在函数参数中收到错误.

错误是没有"As"子句的函数.假定对象的返回类型

这是什么错误.

问候,
Ganesh.S

标签,代码块,HTML字符编码-OriginalGriff [/edit]



i am getting the error in the function parameter.

Error is "function without an ''As'' Clause. return type of object assumed

what is this error.

Regards,
Ganesh.S

[edit]Tags, code blocks, HTML Character encode - OriginalGriff[/edit]

推荐答案

您的函数应返回一个值,并且您没有告诉编译器什么类型的值(整数,字符串等)返回,因此编译器假设yoyuu将返回一个对象.

根据您的设置,这将是警告还是错误

为了消除警告,请在您的函数中将"xxx"作为广告

e,g,

Your function should return a value, and you have not told the compiler what type of value (integer, string etc.) it is returning, so the compiler is assuming yoyuu will return an object.

Depending on the setting you have, this will be a warning or an error

to get rid of the warning, ad As xxx to your function

e,g,

Private Function FindVal(ByVal ID, ByVal Desig) As integer


如果您不想返回值,则不要使用Visual Basic将sub用于此类需求的功能

IF you don''t want to return a value then don''t use a function visual basic uses sub for such a needs

 Public sub findval(byval ID as integer)
 End sub
<\pre>


这篇关于没有As子句的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆