千家信息网

VB.NET如何实现数据自增

发表于:2024-11-11 作者:千家信息网编辑
千家信息网最后更新 2024年11月11日,这篇文章主要为大家展示了"VB.NET如何实现数据自增",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"VB.NET如何实现数据自增"这篇文章吧。VB.NET
千家信息网最后更新 2024年11月11日VB.NET如何实现数据自增

这篇文章主要为大家展示了"VB.NET如何实现数据自增",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"VB.NET如何实现数据自增"这篇文章吧。

VB.NET数据自增的代码如下:

Public Class Sheet1  Private MyWeekMenu As Office.CommandBarButton  Private MyMonthMenu As Office.CommandBarButton  Private MySeriesMenu As Office.CommandBarButton  Private missing = System.Reflection.Missing.Value  Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup  AddMenuBar()  End Sub  Private Sub Sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown  End Sub  Private Sub AddMenuBar()  Try  Dim MyCommandBarPopup As Office.CommandBarPopup = Nothing Dim MyCommandBarMenu As Office.CommandBar = _ CType(Application.CommandBars.ActiveMenuBar, Office.CommandBar)  Dim MyControlsCount As Integer = MyCommandBarMenu.Controls.Count  MyCommandBarPopup = CType(MyCommandBarMenu.Controls.Add( _  Office.MsoControlType.msoControlPopup, missing, missing, _  MyControlsCount, True), Office.CommandBarPopup)  If (MyCommandBarPopup IsNot Nothing) Then  MyCommandBarPopup.Caption = "演示数据自增" MyWeekMenu = CType(MyCommandBarPopup.Controls.Add( _  Office.MsoControlType.msoControlButton, missing, missing, _  missing, True), Office.CommandBarButton)  MyWeekMenu.Caption = "自增星期数据" AddHandler MyWeekMenu.Click, AddressOf MyWeekMenuCommand_Click  MyMonthMenu = CType(MyCommandBarPopup.Controls.Add( _  Office.MsoControlType.msoControlButton, missing, missing, _  missing, True), Office.CommandBarButton)  MyMonthMenu.Caption = "自增月份数据" AddHandler MyMonthMenu.Click, AddressOf MyMonthMenuCommand_Click  MySeriesMenu = CType(MyCommandBarPopup.Controls.Add( _  Office.MsoControlType.msoControlButton, missing, missing, _  missing, True), Office.CommandBarButton)  MySeriesMenu.Caption = "自增序列数据" AddHandler MySeriesMenu.Click, AddressOf MySeriesMenuCommand_Click  End If  Catch ex As Exception  MessageBox.Show(ex.Message, "51cto信息提示", _  MessageBoxButtons.OK, MessageBoxIcon.Error)  End Try  End Sub  '自增星期数据  Private Sub MyWeekMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)  Dim MyRange As Microsoft.Office.Tools.Excel.NamedRange = _ Me.Controls.AddNamedRange(Me.Range("A1", missing), "NamedRange1")  'MyRange.Value2 = "星期一" 'MyRange.AutoFill(Me.Range("A1", "A5"), Excel.XlAutoFillType.xlFillWeekdays)  MyRange.Value2 = "Monday" MyRange.AutoFill(Me.Range("A1", "A5"), Excel.XlAutoFillType.xlFillWeekdays)  End Sub  '自增月份数据  '更多.net源码和实例  Private Sub MyMonthMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)  Dim MyRange As Microsoft.Office.Tools.Excel.NamedRange = _ Me.Controls.AddNamedRange(Me.Range("B1", missing), "NamedRange2")  'MyRange.Value2 = "Jan" MyRange.Value2 = "January" MyRange.AutoFill(Me.Range("B1", "B12"), Excel.XlAutoFillType.xlFillMonths)  End Sub  '自增序列数据  Private Sub MySeriesMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)  Dim MyRange As Microsoft.Office.Tools.Excel.NamedRange = _ Me.Controls.AddNamedRange(Me.Range("C1", missing), "NamedRange3")  MyRange.Value2 = "1975年1月1日 生产日报" MyRange.AutoFill(Me.Range("C1", "C31"), Excel.XlAutoFillType.xlFillSeries)  End Sub  End Class

以上是"VB.NET如何实现数据自增"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

0