您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“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如何實現數據自增”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。