怎么把一段VB代码转化成C#
PrivateSubCommand1_Click()OnErrorResumeNextDimiAsIntegerDimconnAsNewADODB.ConnectionD...
Private Sub Command1_Click()
On Error Resume Next
Dim i As Integer
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lwl.mdb"
conn.Open
rs.Open "select * from lwl", conn, adOpenKeyset, adLockOptimistic
' Set MSChart1.DataSource = rs
With MSChart1
'// 以线条方式显示
.chartType = 3
'// 把刻录改为手工方式
.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
'// 设置最大值
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1000
'// 设置最小值
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
'// 设置每格为 1
.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1
'// 设置收入和兼职收入总列数
.ColumnCount = 2
'//轴坐标标题
.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "日期"
.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "收入"
'//轴坐标标题字体大小的设置
.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15
.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 25
'//设置图表标题
.Title.Text = "日期和收入对应折线图"
'// 显示图例说明
.ShowLegend = True
'// 标记每个点的值
For i = 1 To .Plot.SeriesCollection.Count
.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
Next
If rs.RecordCount > 0 Then
rs.MoveFirst
Else
Exit Sub
End If
For i = 0 To rs.RecordCount - 1
.Column = 1 '收入曲线所在列
.RowCount = rs.RecordCount
.Row = i + 1
.RowLabel = CStr(rs("日期"))
.Data = rs("收入")
.ColumnLabel = "收入" '图例说明文字
'//兼职收入显示
.Column = 2 '兼职收入曲线所在列
.Data = rs("兼职收入")
.ColumnLabel = "兼职收入" '图例说明文字
rs.MoveNext
Next
End With
End Sub
Private Sub Command2_Click() '下列示例设置图表查看距离和轴分段间距。
' Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar
With MSChart1.Plot
' Changes 3d bar chart's viewing.
.DepthToHeightRatio = 2
.WidthToHeightRatio = 2
' Changes the spacing between divisions on the
' X-Axis.
.xGap = 0
' Changes the spacing between divisions on the
' Z-Axis.
.zGap = 0.8
End With
End Sub 展开
On Error Resume Next
Dim i As Integer
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lwl.mdb"
conn.Open
rs.Open "select * from lwl", conn, adOpenKeyset, adLockOptimistic
' Set MSChart1.DataSource = rs
With MSChart1
'// 以线条方式显示
.chartType = 3
'// 把刻录改为手工方式
.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
'// 设置最大值
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1000
'// 设置最小值
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
'// 设置每格为 1
.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1
'// 设置收入和兼职收入总列数
.ColumnCount = 2
'//轴坐标标题
.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "日期"
.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "收入"
'//轴坐标标题字体大小的设置
.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15
.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 25
'//设置图表标题
.Title.Text = "日期和收入对应折线图"
'// 显示图例说明
.ShowLegend = True
'// 标记每个点的值
For i = 1 To .Plot.SeriesCollection.Count
.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
Next
If rs.RecordCount > 0 Then
rs.MoveFirst
Else
Exit Sub
End If
For i = 0 To rs.RecordCount - 1
.Column = 1 '收入曲线所在列
.RowCount = rs.RecordCount
.Row = i + 1
.RowLabel = CStr(rs("日期"))
.Data = rs("收入")
.ColumnLabel = "收入" '图例说明文字
'//兼职收入显示
.Column = 2 '兼职收入曲线所在列
.Data = rs("兼职收入")
.ColumnLabel = "兼职收入" '图例说明文字
rs.MoveNext
Next
End With
End Sub
Private Sub Command2_Click() '下列示例设置图表查看距离和轴分段间距。
' Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar
With MSChart1.Plot
' Changes 3d bar chart's viewing.
.DepthToHeightRatio = 2
.WidthToHeightRatio = 2
' Changes the spacing between divisions on the
' X-Axis.
.xGap = 0
' Changes the spacing between divisions on the
' Z-Axis.
.zGap = 0.8
End With
End Sub 展开
3个回答
展开全部
给你个网站,自动转的
http://www.developerfusion.com/tools/convert/csharp-to-vb/
private void Command1_Click()
{
// ERROR: Not supported in C#: OnErrorStatement
int i = 0;
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
conn = new ADODB.Connection();
rs = new ADODB.Recordset();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\\lwl.mdb";
conn.Open();
rs.Open("select * from lwl", conn, adOpenKeyset, adLockOptimistic);
// Set MSChart1.DataSource = rs
var _with1 = MSChart1;
//// 以线条方式显示
_with1.chartType = 3;
//// 把刻录改为手工方式
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Auto = false;
//// 设置最大值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1000;
//// 设置最小值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0;
//// 设置每格为 1
_with1.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1;
//// 设置收入和兼职收入总列数
_with1.ColumnCount = 2;
////轴坐标标题
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "日期";
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "收入";
////轴坐标标题字体大小的设置
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15;
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 25;
////设置图表标题
_with1.Title.Text = "日期和收入对应折线图";
//// 显示图例说明
_with1.ShowLegend = true;
//// 标记每个点的值
for (i = 1; i <= _with1.Plot.SeriesCollection.Count; i++) {
_with1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint;
}
if (rs.RecordCount > 0) {
rs.MoveFirst();
} else {
return;
}
for (i = 0; i <= rs.RecordCount - 1; i++) {
_with1.Column = 1;
//收入曲线所在列
_with1.RowCount = rs.RecordCount;
_with1.Row = i + 1;
_with1.RowLabel = Convert.ToString(rs("日期"));
_with1.Data = rs("收入");
_with1.ColumnLabel = "收入";
//图例说明文字
////兼职收入显示
_with1.Column = 2;
//兼职收入曲线所在列
_with1.Data = rs("兼职收入");
_with1.ColumnLabel = "兼职收入";
//图例说明文字
rs.MoveNext();
}
}
//下列示例设置图表查看距离和轴分段间距。
private void Command2_Click()
{
// Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar;
var _with2 = MSChart1.Plot;
// Changes 3d bar chart's viewing.
_with2.DepthToHeightRatio = 2;
_with2.WidthToHeightRatio = 2;
// Changes the spacing between divisions on the
// X-Axis.
_with2.xGap = 0;
// Changes the spacing between divisions on the
// Z-Axis.
_with2.zGap = 0.8;
}
http://www.developerfusion.com/tools/convert/csharp-to-vb/
private void Command1_Click()
{
// ERROR: Not supported in C#: OnErrorStatement
int i = 0;
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
conn = new ADODB.Connection();
rs = new ADODB.Recordset();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\\lwl.mdb";
conn.Open();
rs.Open("select * from lwl", conn, adOpenKeyset, adLockOptimistic);
// Set MSChart1.DataSource = rs
var _with1 = MSChart1;
//// 以线条方式显示
_with1.chartType = 3;
//// 把刻录改为手工方式
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Auto = false;
//// 设置最大值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1000;
//// 设置最小值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0;
//// 设置每格为 1
_with1.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1;
//// 设置收入和兼职收入总列数
_with1.ColumnCount = 2;
////轴坐标标题
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "日期";
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "收入";
////轴坐标标题字体大小的设置
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15;
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 25;
////设置图表标题
_with1.Title.Text = "日期和收入对应折线图";
//// 显示图例说明
_with1.ShowLegend = true;
//// 标记每个点的值
for (i = 1; i <= _with1.Plot.SeriesCollection.Count; i++) {
_with1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint;
}
if (rs.RecordCount > 0) {
rs.MoveFirst();
} else {
return;
}
for (i = 0; i <= rs.RecordCount - 1; i++) {
_with1.Column = 1;
//收入曲线所在列
_with1.RowCount = rs.RecordCount;
_with1.Row = i + 1;
_with1.RowLabel = Convert.ToString(rs("日期"));
_with1.Data = rs("收入");
_with1.ColumnLabel = "收入";
//图例说明文字
////兼职收入显示
_with1.Column = 2;
//兼职收入曲线所在列
_with1.Data = rs("兼职收入");
_with1.ColumnLabel = "兼职收入";
//图例说明文字
rs.MoveNext();
}
}
//下列示例设置图表查看距离和轴分段间距。
private void Command2_Click()
{
// Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar;
var _with2 = MSChart1.Plot;
// Changes 3d bar chart's viewing.
_with2.DepthToHeightRatio = 2;
_with2.WidthToHeightRatio = 2;
// Changes the spacing between divisions on the
// X-Axis.
_with2.xGap = 0;
// Changes the spacing between divisions on the
// Z-Axis.
_with2.zGap = 0.8;
}
展开全部
给你个网站,自动转的
http://www.developerfusion.com/tools/convert/csharp-to-vb/
private void Command1_Click()
{
// ERROR: Not supported in C#: OnErrorStatement
int i = 0;
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
conn = new ADODB.Connection();
rs = new ADODB.Recordset();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\\lwl.mdb";
conn.Open();
rs.Open("select * from lwl", conn, adOpenKeyset, adLockOptimistic);
// Set MSChart1.DataSource = rs
var _with1 = MSChart1;
//// 以线条方式显示
_with1.chartType = 3;
//// 把刻录改为手工方式
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Auto = false;
//// 设置最大值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1000;
//// 设置最小值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0;
//// 设置每格为 1
_with1.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1;
//// 设置收入和兼职收入总列数
_with1.ColumnCount = 2;
////轴坐标标题
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "日期";
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "收入";
////轴坐标标题字体大小的设置
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15;
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 25;
////设置图表标题
_with1.Title.Text = "日期和收入对应折线图";
//// 显示图例说明
_with1.ShowLegend = true;
//// 标记每个点的值
for (i = 1; i <= _with1.Plot.SeriesCollection.Count; i++) {
_with1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint;
}
if (rs.RecordCount > 0) {
rs.MoveFirst();
} else {
return;
}
for (i = 0; i <= rs.RecordCount - 1; i++) {
_with1.Column = 1;
//收入曲线所在列
_with1.RowCount = rs.RecordCount;
_with1.Row = i + 1;
_with1.RowLabel = Convert.ToString(rs("日期"));
_with1.Data = rs("收入");
_with1.ColumnLabel = "收入";
//图例说明文字
////兼职收入显示
_with1.Column = 2;
//兼职收入曲线所在列
_with1.Data = rs("兼职收入");
_with1.ColumnLabel = "兼职收入";
//图例说明文字
rs.MoveNext();
}
}
//下列示例设置图表查看距离和轴分段间距。
private void Command2_Click()
{
// Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar;
var _with2 = MSChart1.Plot;
// Changes 3d bar chart's viewing.
_with2.DepthToHeightRatio = 2;
_with2.WidthToHeightRatio = 2;
// Changes the spacing between divisions on the
// X-Axis.
_with2.xGap = 0;
// Changes the spacing between divisions on the
// Z-Axis.
_with2.zGap = 0.8;
}
http://www.developerfusion.com/tools/convert/csharp-to-vb/
private void Command1_Click()
{
// ERROR: Not supported in C#: OnErrorStatement
int i = 0;
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
conn = new ADODB.Connection();
rs = new ADODB.Recordset();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\\lwl.mdb";
conn.Open();
rs.Open("select * from lwl", conn, adOpenKeyset, adLockOptimistic);
// Set MSChart1.DataSource = rs
var _with1 = MSChart1;
//// 以线条方式显示
_with1.chartType = 3;
//// 把刻录改为手工方式
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Auto = false;
//// 设置最大值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1000;
//// 设置最小值
_with1.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0;
//// 设置每格为 1
_with1.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 1;
//// 设置收入和兼职收入总列数
_with1.ColumnCount = 2;
////轴坐标标题
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle = "日期";
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle = "收入";
////轴坐标标题字体大小的设置
_with1.Plot.Axis(VtChAxisIdX, 0).AxisTitle.VtFont.Size = 15;
_with1.Plot.Axis(VtChAxisIdY, 0).AxisTitle.VtFont.Size = 25;
////设置图表标题
_with1.Title.Text = "日期和收入对应折线图";
//// 显示图例说明
_with1.ShowLegend = true;
//// 标记每个点的值
for (i = 1; i <= _with1.Plot.SeriesCollection.Count; i++) {
_with1.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint;
}
if (rs.RecordCount > 0) {
rs.MoveFirst();
} else {
return;
}
for (i = 0; i <= rs.RecordCount - 1; i++) {
_with1.Column = 1;
//收入曲线所在列
_with1.RowCount = rs.RecordCount;
_with1.Row = i + 1;
_with1.RowLabel = Convert.ToString(rs("日期"));
_with1.Data = rs("收入");
_with1.ColumnLabel = "收入";
//图例说明文字
////兼职收入显示
_with1.Column = 2;
//兼职收入曲线所在列
_with1.Data = rs("兼职收入");
_with1.ColumnLabel = "兼职收入";
//图例说明文字
rs.MoveNext();
}
}
//下列示例设置图表查看距离和轴分段间距。
private void Command2_Click()
{
// Change the chart type to 3D Bar.
MSChart1.chartType = VtChChartType3dBar;
var _with2 = MSChart1.Plot;
// Changes 3d bar chart's viewing.
_with2.DepthToHeightRatio = 2;
_with2.WidthToHeightRatio = 2;
// Changes the spacing between divisions on the
// X-Axis.
_with2.xGap = 0;
// Changes the spacing between divisions on the
// Z-Axis.
_with2.zGap = 0.8;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按照c#规则重写一遍呗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询