Dim d As Date = new Date(Date.Today.Year, 1, 1)
Dim w = d.DayOfWeek
Dim startdate As Date
Dim Enddate As Date
Dim d1 As Date =Date.Today
Dim d2 As Date = new Date(d1.year,1,1)
Dim d3 As Date =New Date(d1.year, 12, 31)
Output.show(format(d1,"yyyy") & "年第" & DateDiff("ww",d2,d1) +1 & "周")
Dim ii As Integer= DateDiff("ww",d2,d1)+1
startdate = d.AddDays(8-w).AddDays(7*(val(ii)-2))
Enddate = startdate.AddDays(6)
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim tbl As DataTable = DataTables("汇总统计") '定义一个变量tbl引用数据表
Dim lst As List(Of String) = tbl.GetValues("日","年='" & Date.today.Year & "' and [周] = '" & ii & "'") '获得产品名称集合
Chart = e.Form.Controls("Chart5") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length =7 '设置图系的长度
Series.DataLabelText = "{#YVAL}"
'msgbox(startdate & "-" & Enddate )
Dim dd As Integer= startdate.Day
For i As Integer = 0 To 6 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Dim m As Double = tbl.Compute("Sum(收款)","[日] = " & dd+i)
Series.Y(i) = m '指定垂直坐标
Chart.AxisX.SetValueLabel(i,dd+i & "日")'指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
初步实现数据可以按照预期显示周一到周日
上述代码貌似有些没有和老师思路一致
老师是否可以指导下二楼方法呢?另外上述代码还有没有更为简便的写法呢?