0

我在 C# 中的这个函数有问题。我想将其转换为 VB.NET

这段代码是 C#

public Frm_Sched()
{
    dayView1.NewAppointment += new Calendar.NewAppointmentEventHandler(dayView1_NewAppointment);
}

void dayView1_NewAppointment(object sender, Calendar.NewAppointmentEventArgs args)
{
    Calendar.Appointment m_Appointment = new Calendar.Appointment();

    m_Appointment.StartDate = args.StartDate;
    m_Appointment.EndDate = args.EndDate;
    m_Appointment.Title = args.Title;

    oApp.Add(m_Appointment);
}

如何将其转换为 VB.NET?我想在我的表单加载中调用这个事件

Private Sub Frm_Sched_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub

请帮忙。

4

1 回答 1

3

直接翻译是:

Public Sub New()
    AddHandler dayView1.NewAppointment, AddressOf dayView1_NewAppointment
End Sub

Private Sub dayView1_NewAppointment(sender As Object, args As Calendar.NewAppointmentEventArgs)
    Dim m_Appointment = New Calendar.Appointment()

    m_Appointment.StartDate = args.StartDate
    m_Appointment.EndDate = args.EndDate
    m_Appointment.Title = args.Title

    oApp.Add(m_Appointment)
End Sub

您总是可以使用像这样的自动翻译器,但它们在某些情况下通常会失败,例如不安全的代码(显然)和事件订阅。

于 2012-07-31T07:02:31.423 回答