How to realize data self-increment by VB.NET
This article mainly shows you "how VB. NET realizes data self-increment", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "how VB. NET realizes data self-increment".
The VB. NET data autoincrement code is as follows:
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 = "Demo Data Self-Increasing" MyWeekMenu = CType (MyCommandBarPopup.Controls.Add( _ Office.MsoControlType.msoControlButton, missing, missing, _ missing, True), Office.CommandBarButton) MyWeekMenu.Caption = "Self-increasing Week Data" AddHandler MyWeekMenu.Click, AddressOf MyWeekMenuCommand_Click MyMonthMenu = CType (MyCommandBarPopup.Controls.Add( _ Office.MsoControlType.msoControlButton, missing, missing, _ missing, True), Office.CommandBarButton) MyMonthMenu.Caption = "Self-increasing Month Data" AddHandler MyMonthMenu.Click, AddressOf MyMonthMenuCommand_Click MySeriesMenu = CType (MyCommandBarPopup.Controls.Add( _ Office.MsoControlType.msoControlButton, missing, missing, _ missing, True), Office.CommandBarButton) MySeriesMenu.Caption = "Self-increasing Sequence Data" AddHandler MySeriesMenu.Click, AddressOf MySeriesMenuCommand_Click End If Catch ex As Exception MessageBox.Show (ex.Message, "51cto Message Prompt", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub 'Self-increasing Week Data 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 = "Monday" 'MyRange.AutoFill (Me.Range("A1", "A5"), Excel.XlAutoFillType.xlFillWeekdays) MyRange.Value2 = "Monday" MyRange.AutoFill (Me.Range("A1", "A5"), Excel.XlAutoFillType.xlFillWeekdays) End Sub 'Self-increasing month data' More. net source codes and examples 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 'Self-increasing Sequence Data 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 = "January 1, 1975 Production Daily" MyRange.AutoFill(Me.Range("C1", "C31"), Excel.XlAutoFillType.xlFillSeries) End Sub End Class Above is "VB. NET how to achieve data self-increment" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!