0
我有一個代碼,但無法讓它工作。 我有一個名稱空間和一個類和一個子.vb網站。 然後在我的Index.aspx網站我不能調用這個子 的2位是在我的項目的根目錄,項目的名稱是CalendarWeek從命名空間中的類調用一個SUB VB.Net
我WeekController.vb是
Imports System
Imports System.Web.UI.WebControls.Calendar
Imports System.Globalization
Namespace CalendarWeekController
Public Class WeekShow
Shared Sub Main()
' Gets the Calendar instance associated with a CultureInfo.
Dim myCI As New CultureInfo("da-DK")
Dim myCal As Calendar = myCI.Calendar
' Gets the DTFI properties required by GetWeekOfYear.
Dim myCWR As CalendarWeekRule = myCI.DateTimeFormat.CalendarWeekRule
Dim myFirstDOW As DayOfWeek = myCI.DateTimeFormat.FirstDayOfWeek
' Displays the number of the current week relative to the beginning of the year.
Console.WriteLine("The CalendarWeekRule used for the en-US culture is {0}.", myCWR)
Console.WriteLine("The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW)
Console.WriteLine("Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW))
' Displays the total number of weeks in the current year.
Dim LastDay = New System.DateTime(DateTime.Now.Year, 12, 31)
Console.WriteLine("There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year)
End Sub 'Main
End Class
結束名稱空間
而且我的Index.aspx是
<%@ Import Namespace="CalendarWeekController" %>
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = False Then
Call WeekShow(Sub Main)
End If
End Sub
%>
</div>
</form>
</body>
</html>
運行的網站時,我得到這個錯誤。 描述:解析服務此請求所需的資源時發生錯誤。請檢查以下特定的分析錯誤詳細信息並適當修改您的源文件。
解析器錯誤消息:無法加載類型'CalendarWeek.CalendarWeekController'。
源錯誤:
1行:<%@導入命名空間= 「CalendarWeekController」 %> 第2行:<%@頁面語言= 「VB」 AutoEventWireup = 「假」 繼承= 「CalendarWeek.CalendarWeekController」 %> 第3行: 第4行:
嗨,如果我改變了代碼幾乎工作,現在我得到這個錯誤: 聲明不能在方法體中出現。假定方法結束。而這一個:'End Sub'前面必須有一個匹配的'Sub'。 – 2010-11-24 21:42:32