这段VBA代码如何转换成VB.NET

ryu_kanka 2009-04-10 02:52:14
RT

VBA代码如下:


Sub Macro1()

With ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "日付"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "障害件数"
End With

End Sub


转换成VB.NET代码应该怎样写呢?
...全文
106 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
清晨曦月 2009-04-12
  • 打赏
  • 举报
回复
如果是OFFICE的,那这段代码吊不用改就可以用在.NET上

但是要明确指出ActiveChart是啥玩意,

Sub Macro1()

With UROBJ.ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "日付"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "障害件数"
End With

End Sub
a854468521 2009-04-12
  • 打赏
  • 举报
回复
’添加EXCEL引用:
'Microsoft Office 12.0 Object Library
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Core
Sub Macro1()
Dim Exc As New Microsoft.Office.Interop.Excel.Application
Exc.Workbooks.Add()
With Exc.ActiveChart
.Axes(Microsoft.Office.Core.XlAxisType.xlCategory, Microsoft.Office.Core.XlAxisGroup.xlPrimary).HasTitle = True
.Axes(Microsoft.Office.Core.XlAxisType.xlCategory, Microsoft.Office.Core.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "日付"
.Axes(Microsoft.Office.Core.XlAxisType.xlValue, Microsoft.Office.Core.XlAxisGroup.xlPrimary).HasTitle = True
.Axes(Microsoft.Office.Core.XlAxisType.xlValue, Microsoft.Office.Core.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "障害件数"
End With

End Sub
scott156 2009-04-10
  • 打赏
  • 举报
回复
我不是很清楚 ActiveChart 是啥,不过按VB.NET语法来说

Sub Macro1()
With ActiveChart
.Add("A", True)
Dim B As Boolean
B = .Item("A")
End With
End Sub


你写的语法是没有错的。.NET通用

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧