Home

Examples for charts with VB?

Anyone had success creating charts with vb? The C# example is the following:
var customers = new[] { new { Name = "John", TotalOrders = 100 }, new { Name = "Mary", TotalOrders = 130 }, new { Name = "Sara", TotalOrders = 140 }, new { Name = "Paul", TotalOrders = 125 }, }; customers.Chart (c => c.Name, c => c.TotalOrders).Dump(); // Don't forget to Dump it!

I tried to convert it like this but no luck. I'm assuming it works with vb but can't find examples anywhere.
Dim customers = { New With{.Name = "John", .TotalOrders = 100}, New With{.Name = "Mary", .TotalOrders = 130}, New With{.Name = "Sara", .TotalOrders = 140}, New With{.Name = "Paul", .TotalOrders = 125} } customers.Chart(customers.Select(Function(x)x.Name),customers.Select(Function(x)x.totalorders)).Dump()

Comments

  • C# c => c.Name translates to VB.NET Function(c) c.Name
    Dim customers = {
      New With {.Name = "John", .TotalOrders = 100},
      New With {.Name = "Mary", .TotalOrders = 130},
      New With {.Name = "Sara", .TotalOrders = 140},
      New With {.Name = "Paul", .TotalOrders = 125}
    }
    customers.Chart(Function(c) c.Name, Function(c) c.totalorders).Dump()
  • daniel5643523, for future reference try an online converter such as Telerik's. It's not foolproof but it does work in this case.
Sign In or Register to comment.