Skip to content

Instantly share code, notes, and snippets.

View pradesa's full-sized avatar

pradesa pradesa

  • design kamarku
  • cirebon
View GitHub Profile
@pradesa
pradesa / CR-Connection-VB.net
Created May 17, 2013 09:03
CR-Connection-VB.net
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class ClassCetak
Public Shared Sub _ConReport()
Dim _ReportLogonInfos As New TableLogOnInfos
Dim _ReportLogonInfo As New TableLogOnInfo
Dim _ReportConInfo As New ConnectionInfo
Dim _Tables As Tables
Dim _Table As Table
@pradesa
pradesa / Find String in DataGridView, VB.Net
Last active December 17, 2015 10:49
Find String in DataGridView
'Prosesnya adalah membandingkan string dari Object Textbox dengan Kolom di DataGridView
'Kalo datanya ketemu, akan di set sebagai Current Row
Public Shared Sub _FindRow(ByVal _DataGridView As DataGridView, ByVal _String As String)
Dim data As String
For x = 0 To _DataGridView.Rows.Count - 1
data = _DataGridView.Rows(x).Cells(1).Value
Try
If UCase(data.Substring(0, _STring.Length)) = UCase(_STring) Then
_DataGridView.CurrentCell = _DataGridView.Rows(x).Cells(0)
@pradesa
pradesa / Export to Excel From DataGridView VB.Net, XML
Created June 8, 2013 22:07
Use XML, Deskripsi tiap row Menyusul Source : Mbah google ( authornya lupa ) di modifikasi sedikit.
Public Shared Sub _ExporttoExcel(ByVal _DataGridView As DataGridView, ByVal _Form As Form)
Dim Excel As New IO.StreamWriter(Application.StartupPath & "\Export.xls", False)
Dim _Tmp As String = _Form.Text
Dim _totalRow As Integer = 0
Excel.WriteLine("<?xml version=""1.0""?>")
Excel.WriteLine("<?mso-application progid=""Excel.Sheet""?>")
Excel.WriteLine("<ss:Workbook xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet"">")
Excel.WriteLine(" <ss:Styles>")
Excel.WriteLine(" <ss:Style ss:ID=""1"">")
Excel.WriteLine(" <ss:Font ss:Bold=""0""/>")
@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
@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 / 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 / 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"
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 / 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
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;")