Skip to content

Instantly share code, notes, and snippets.

View pradesa's full-sized avatar

pradesa pradesa

  • design kamarku
  • cirebon
View GitHub Profile
Imports System.Data.SqlClient
Imports System.Data.Sql
Public Class nPagingData
Public Property TombolFirst() As ToolStripButton
Public Property TombolPrev() As ToolStripButton
Public Property TombolNext() As ToolStripButton
Public Property TombolLast() As ToolStripButton
Public Property TextCurrentPage() As ToolStripTextBox
Public Property TextTotalPage() As ToolStripTextBox
'==================================================
@pradesa
pradesa / gist:6667853
Last active December 23, 2015 17:19
Paging Data dengan VB.Net
Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class PagingData
Private Shared iMaxRow As Integer = 20
Private Shared iCurrentIndex As Integer
Private Shared iTotalIndex As Integer
Private Shared iCurrentPage As Integer
Private Shared iTotalPage As Integer
Public Shared Sub ServerList(ByVal ComboInstance As ComboBox)
Dim _server As String = String.Empty
Dim _Instance = SqlDataSourceEnumerator.Instance
Dim _Table = _Instance.GetDataSources
For Each _row In _Table.Rows
_server = String.Empty
_server = If(_row("InstanceName").ToString.Length > 0, String.Format("{0}\{1}", _row("ServerName"), _row("InstanceName")), _row("ServerName"))
ComboInstance.Items.Add(_server)
Next
End Sub
Public Shared Function _Excel2003(ByVal DataImport As DataGridView, ByVal _Path As String) As Double
Dim _Conn As System.Data.OleDb.OleDbConnection
Dim _dataSet As System.Data.DataSet
Dim _dataAdapter As System.Data.OleDb.OleDbDataAdapter
Dim _RowCount As Integer = 0
Dim _ColCount As Integer = 0
Dim _ItemCOunt As Long
Dim _FieldCount As Integer
Try
_Conn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + Trim(_Path) + "';Extended Properties=Excel 8.0;")
@pradesa
pradesa / List File Name with listview, VB.Net
Created June 8, 2013 22:33
Menampilkan daftar File dengan extensi tertentu. mengunakan Listview
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If Len(Trim(tPath.Text)) > 0 Then
Dim _FileSize As String = ""
Dim _Dir As New IO.DirectoryInfo(tPath.Text)
Dim AryFi As IO.FileInfo() = _Dir.GetFiles("*.DBF")
Dim Fi As IO.FileInfo
Dim _ListItem As ListViewItem
LvTable.Items.Clear()
Dim i As Integer = 0
For Each Fi In AryFi
Private Sub Tombol() Handles Button1.Click
Dim sPath As String
OD.Filter = "DBF File (*.DBF)|*.Dbf"
If OD.ShowDialog = Windows.Forms.DialogResult.OK Then
sPath = OD.FileName 'get the path
sPath = StrReverse(sPath) 'reverse the string
sPath = Mid(sPath, InStr(sPath, "\"), Len(sPath)) 'extract from the first slash
sPath = StrReverse(sPath) 'reverse it again
tPath.Text = sPath
End If
@pradesa
pradesa / Read DBF File From VB.Net
Created June 8, 2013 22:29
Membaca File DBF Hal2 yang perlu di perhatikan 1. Instal VFPOLEDB, silakan cari di mbah Google. 2. tPath.text = di isi hanya Path nya saja ga pake File name .DBF
Private Sub _TampilData(ByVal _SQLQuery As String)
Try
Dim sConn As String = "Provider=VFPOLEDB.1;Data Source=" & tPath.Text & ";Password='';Collating Sequence=MACHINE"
Dim oConn As OleDbConnection = New OleDbConnection(sConn)
Dim oCmd As OleDbCommand = New OleDbCommand(_SQLQuery, oConn)
Dim oDa As New OleDbDataAdapter(oCmd)
Dim oDS As New DataSet
oDa.Fill(oDS)
DataGrid1.DataSource = oDS.Tables(0)
Label1.Text = oDS.Tables(0).Rows.Count & " Record ditemukan"
@pradesa
pradesa / Text Box Numeric Only, VB.Net
Last active December 18, 2015 05:59
untuk pemanggilannya di lakukan di event Keypress --> e.Handled =_TextAngka(Asc(e.KeyChar))
Public Shared Function _TextAngka(ByVal kode As String, Optional ByVal spasi As Boolean = False) As Boolean
'ex to use : e.Handled = EtcClass._TextAngka(Asc(e.KeyChar))
Select Case kode
Case 40 To 57
Return False
Case 8
Return False
Case 32
If spasi Then
Return False
@pradesa
pradesa / Automatic Uppercase, VB.Net
Last active December 18, 2015 05:59
di panggil pada saat Form di Load. Pemanggilannya cukup _HurufBesar(me)
Public Shared Sub _HurufBesar(ByVal root As Control)
Dim _Obj As New ArrayList
_Obj.Add(root)
Do Until (_Obj.Count = 0)
Dim Cur As Control = _Obj(0)
_Obj.RemoveAt(0)
For Each _Obj2 As Control In Cur.Controls
_Obj.Add(_Obj2)
Next
Dim _Btn As TextBox = TryCast(Cur, TextBox)
@pradesa
pradesa / Export to Excel From DataGridView VB.Net, Microsoft.Office.Interop
Created June 8, 2013 22:10
Use Microsoft.Office.Interop, Source : Mbah Google ( lupa siapa author nya ) sedikit di modifikasi. penjelasan per line menyusul.
Public Shared Sub _ExporttoExcel1(ByVal _DataGrid As DataGridView, ByVal _form As Form)
If _DataGrid.Rows.Count > 0 Then
Dim _str As String = _form.Text
Dim _totalExport As Integer = _DataGrid.Rows.Count
Dim _dset As New DataSet
_dset.Tables.Add()
For i = 0 To _DataGrid.ColumnCount - 1
_dset.Tables(0).Columns.Add(_DataGrid.Columns(i).HeaderText)
Next i
'tambahkan row