XlBordersIndex enumeration (Excel) in VB.Net

XlBordersIndex enumeration (Excel) For more information: excel.xlbordersindex

Read more »

How to make datagridview cell readonly in vb.net

Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick If e.RowIndex < 0 Then Exit Sub End If If e.ColumnIndex = 1 Then DataGridView1.CurrentCell.ReadOnly = False Else DataGridView1.CurrentCell.ReadOnly = True End If End Sub

Read more »

How to Export Data to Excel in VB.NET with type object

Public Class Form1 Private Sub ExportExcel() Dim xlApp As Object If xlApp Is Nothing Then MessageBox.Show(“Excel is not properly installed!!”) Return End If Dim i As Integer Dim xlWorkBook As Object Dim xlhdWorkSheet As Object xlWorkBook = xlApp.Workbooks.Add…

Read more »

How to Export Data to Excel in VB.NET

Set target framework: .Net framework 4 Add references: Microsoft.Office.Interop.Excel Example code: Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub ExportExcel() Dim xlApp As Excel.Application = New Microsoft.Office.Interop.Excel.Application() If xlApp Is Nothing Then MessageBox.Show(“Excel is not properly installed!!”)…

Read more »

Write and read ini file with VB.Net

Private Declare Auto Function GetPrivateProfileString Lib “kernel32” (ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As StringBuilder, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer…

Read more »

Check directory exists path with VB.NET

Imports namespace System.IO as first.   If Directory.Exists(Directory Path) = False Then MsgBox(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) End If  

Read more »

Enter only number on Text box with VB.Net

  If Char.IsDigit(e.KeyChar) Or Asc(e.KeyChar) = 8 Then e.Handled = False Else e.Handled = True End If  

Read more »

How To Show Month First With VB.Net?

Function show month first for VB.Net Public Function Public Function MonthFirst(ByVal pDate As Object) As Object On Error GoTo MonthFirst_Err MonthFirst = DateSerial(Year(pDate), Month(pDate), 1) MonthFirst_Exit: Exit Function MonthFirst_Err: MonthFirst = DateSerial(Year(Now), Month(Now), 1) Resume MonthFirst_Exit End Function…

Read more »

How to show end of month with VB.Net?

Function show end of month for VB.Net Public Function MonthEnd(ByVal pDate As Object) As Object On Error GoTo MonthEnd_Err Dim dd As Integer dd = DateAndTime.Day((DateSerial(Year(pDate), Month(pDate), 28).AddDays(4))) MonthEnd = DateSerial(Year(pDate), Month(pDate), 28).AddDays(4).AddDays(-dd) MonthEnd_Exit: Exit Function MonthEnd_Err: MonthEnd…

Read more »