我正在尝试将函数值加载到Literal2.Text中。
我收到错误
没有为参数' LoadMenu'指定ErrorArgument。 '公众 函数LoadMenuActivity(LoadMenu As String)As String'
我在页面加载上调用函数如下:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Literal2.Text = AllFunc.LoadMenuActivity
End If
End Sub
这是我的班级:
公共类AllFunc
Public Function LoadMenuActivity(ByVal LoadMenu As String) As String
Dim strCON As String = "Data Source=localhost;Initial Catalog=TAPVendor;Integrated Security=True"
Dim strSQL = "SELECT * FROM dbo.tbl_Message WHERE UserID = 'RAN' ORDER BY ID DESC"
Dim da As New SqlClient.SqlDataAdapter(strSQL, strCON)
Dim dt As New DataTable
da.Fill(dt)
Dim display As String = Nothing
Dim sb As StringBuilder = New StringBuilder()
Dim counter As Integer = Nothing
For i As Integer = 0 To dt.Rows.Count - 1
counter = counter + 1
Dim MyString As String
MyString = dt.Rows(i).Item("Timestamp")
Dim MyDateTime As DateTime
MyDateTime = New DateTime
MyDateTime = DateTime.ParseExact(MyString, "yyyy-MM-dd HH:mm:ss tt", Nothing)
Dim t As TimeSpan = DateTime.Now - MyDateTime
If t.TotalSeconds > 1 Then
display = t.Seconds.ToString() + " sec ago"
End If
If t.TotalSeconds > 60 Then
display = t.Minutes.ToString() + " mins ago"
End If
If t.TotalHours > 1 Then
display = t.Hours.ToString() + " hrs ago"
End If
If t.TotalDays > 1 Then
display = t.Days.ToString() + " days ago"
End If
sb.AppendFormat("<li class=""divider""></li>" &
" <li><a href=""#"">" &
"<div>" &
"<i class=""" & dt.Rows(i).Item("Icon") & """></i> " & dt.Rows(i).Item("Alert") & "" &
"<span class=""pull-right text-muted small"">" & display & "</span></div></a></li>")
If counter = 5 Then
Exit For
End If
Next
Return LoadMenu
End Function
End Class
我做错了什么?
答案 0 :(得分:1)
与错误消息一样,您在调用LoadMenuActivity时没有指定参数。你必须调用LoadMenuActivity(&#34; Some string&#34;)。
答案 1 :(得分:0)
()
内的参数需要传递一个字符串。此外,该功能需要是一个共享功能,以这种方式调用它。
Literal2.Text = AllFunc.LoadMenuActivity("some string here")