goicox
goicox

Reputation: 41

Vb.net equivalent of C#

What is the equivalent vb.net code of the corresponding MouseDown event shown below (C#)? How should I implement this event in vb.net?

Thank you in advance, Goicox

var model = new PlotModel("MouseDown HitTestResult", "Reports the index of the nearest point.");

var s1 = new LineSeries();
s1.Points.Add(new DataPoint(0, 10));
s1.Points.Add(new DataPoint(10, 40));
s1.Points.Add(new DataPoint(40, 20));
s1.Points.Add(new DataPoint(60, 30));
model.Series.Add(s1);
s1.MouseDown += (s, e) =>
            {
                model.Subtitle = "Index of nearest point in LineSeries: " + Math.Round(e.HitTestResult.Index);
                model.InvalidatePlot(false);
            };

Upvotes: 0

Views: 254

Answers (2)

Dave Doknjas
Dave Doknjas

Reputation: 6542

You'll need to use a VB 'Sub' lambda (available in VS 2010 and beyond):

AddHandler s1.MouseDown, Sub(s, e)
    model.Subtitle = "Index of nearest point in LineSeries: " & Math.Round(e.HitTestResult.Index)
    model.InvalidatePlot(False)
    End Sub

Upvotes: 0

Pakk
Pakk

Reputation: 1339

Simple convertion should do it :

Dim model = New PlotModel("MouseDown HitTestResult", "Reports the index of the nearest point.")

Dim s1 = New LineSeries()
s1.Points.Add(New DataPoint(0, 10))
s1.Points.Add(New DataPoint(10, 40))
s1.Points.Add(New DataPoint(40, 20))
s1.Points.Add(New DataPoint(60, 30))
model.Series.Add(s1)
s1.MouseDown += Function(s, e) 
model.Subtitle = "Index of nearest point in LineSeries: " &         Math.Round(e.HitTestResult.Index)
model.InvalidatePlot(False)

End Function

Sources : http://www.developerfusion.com/tools/convert/csharp-to-vb/

Upvotes: 1

Related Questions