Pages

Wednesday, June 30, 2010

Menghitung Jumlah Total Nominal Pada DataGridView

Fungsi berikut untuk menghitung Total_Belanja pada DataGridView:

Private Sub Hitung()
   Dim totalbelanja As Long
   totalbelanja = 0
   For t As Integer = 0 To DataGridView1.Rows.Count - 1
      totalbelanja = totalbelanja + Val(DataGridView1.Rows(t).Cells(index).Value)
   Next
   Label1.Text = totalbelanja
End Sub

Mengubah Ukuran Kertas dan Orientasi Laporan Pada Crystal Report

Seringkali kita ingin mendesain laporan dengan orientasi landscape atau ukuran kertas tertentu. Berikut ini adalah langkah-langkahnya. Pada jendela Visual Basic 2008 pilih menu Crystal Reports kemudian pilih Design lalu Printer Setup. Pada kotak dialog Print Setup pilih Orientation lalu ubah menjadi Portrait/Landscape kemudian OK. Pada kotak dialog Print Setup pilih Paper kemudian ubah ukuran kertas lalu OK.

Window Visual Basic 2008

Kotak Dialog Print Setup

Tuesday, June 29, 2010

Navigasi Record Pada VB 2008

Navigasi record adalah berpindah antara record satu ke record yang lainnya (bisa next, previous, first, last). Kunci utama dari syntax navigasi record terletak pada row index. Misalkan kita membuat sebuah subroutine dengan nama NavigasiRecord() seperti di bawah ini:

Private Sub NavigasiRecord()
     txtFirstName.Text = ds.Tables("AddressBook").Rows(inc).Item(1)
     txtSurname.Text = ds.Tables("AddressBook").Rows(inc).Item(2)
End Sub

Syntax untuk navigasi menuju record selanjutnya adalah:

If inc <> MaxRows - 1 Then
     inc = inc + 1
     NavigasiRecord()
Else
     MsgBox("Tidak ada record.")
End If

Syntax untuk navigasi record sebelumnya adalah:


If inc > 0 Then
     inc = inc - 1
     NavigasiRecord()
ElseIf inc = -1 Then
     MsgBox("Tidak ada records.")
ElseIf inc = 0 Then
     MsgBox("Record pertama.")
End If


Syntax untuk navigasi record menuju record terakhir adalah:

If inc <> MaxRows - 1 Then
     inc = MaxRows - 1
     NavigasiRecord()
End If

Syntax untuk navigasi menuju record pertama adalah:

If inc <> 0 Then
     inc = 0
     NavigasiRecord()
End If

Sunday, June 27, 2010

Router Port Forwarding

This section was will show you how to forward ports you’ve just opened to your router. Since I don’t own every router in existence, I’ll show you what it takes for the LinksysWireless Broadband Router to have ports forwarded to it. The concept is the same for all routers and once you familiarize yourself with the steps, you should be able to navigate through your router settings with ease.

First you need to access your router. Open your web browser then type 192.168.1.1 in the address bar. A user name and password box should appear like the one below.


The factory password for this router is admin, leave the user name blank. Some routers may be admin as the user name with the password area blank. Check the documentation that came with your router or refer yourself to the company website to figure out what this is for your router.
NOTE: Highly recommend you changing that password from the factory setting ASAP if it still exists.

Once you type your password, the router settings should be displayed. Select Application & Gaming.


This screen is very easy to handle once you get familiar with it.


  • Application: Input a small abbreviation so you know what program you’re forwarding the ports for.
  • Start to End: A program will need a range of ports forwarded (i.e. 21000-21005). Under start, type the initial port and under end type the last port of the range.
  • Protocol: Select the one that the port utilizes.
  • IP Address: Type your computer IP address. Like was saying before; you complete this process and reboot your PC, the IP might change (Dynamic IP). Therefore, this setting would not be accurate and your ports will no longer be forwarded. Please use static IP Address in this case.
  • Enable: Self Explanatory.
Here is one good thing about the forwarding part. Let’s say you have a range of 10 consecutive ports to forwards (1100 – 1110). For the router settings you just type the start and finish but you’ll have to do each individual one and if the selection is both for all, you just doubled your work. No biggie, right?!

Save your settings and restart your system.

Ethernet Cable: Color-Code Standards

The information listed here is to assist Network Administrators in the color coding of Ethernet cables. Please be aware that modifying Ethernet cables improperly may cause loss of network connectivity.

Straight-Through Ethernet Cable


Crossover Ethernet Cable

Ethernet Cable Instructions:
  1. Pull the cable off the reel to the desired length and cut. If you are pulling cables through holes, its easier to attach the RJ-45 plugs after the cable is pulled. The total length of wire segments between a PC and a hub or between two PC's cannot exceed 100 Meters (328 feet) for 100BASE-TX and 300 Meters for 10BASE-T.
  2. Start on one end and strip the cable jacket off (about 1") using a stripper or a knife. Be extra careful not to nick the wires, otherwise you will need to start over.
  3. Spread, untwist the pairs, and arrange the wires in the order of the desired cable end. Flatten the end between your thumb and forefinger. Trim the ends of the wires so they are even with one another, leaving only 1/2" in wire length. If it is longer than 1/2" it will be out-of-spec and susceptible to crosstalk. Flatten and insure there are no spaces between wires.
  4. Hold the RJ-45 plug with the clip facing down or away from you. Push the wires firmly into the plug. Inspect each wire is flat even at the front of the plug. Check the order of the wires. Double check again. Check that the jacket is fitted right against the stop of the plug. Carefully hold the wire and firmly crimp the RJ-45 with the crimper.
  5. Check the color orientation, check that the crimped connection is not about to come apart, and check to see if the wires are flat against the front of the plug. If even one of these are incorrect, you will have to start over. Test the Ethernet cable.

Ethernet Cable Tips:
  • A straight-thru cable has identical ends.
  • A crossover cable has different ends.
  • A straight-thru is used as a patch cord in Ethernet connections.
  • A crossover is used to connect two Ethernet devices without a hub or for connecting two hubs.
  • A crossover has one end with the Orange set of wires switched with the Green set.
  • Odd numbered pins are always striped, even numbered pins are always solid colored.
  • Looking at the RJ-45 with the clip facing away from you, Brown is always on the right, and pin 1 is on the left.
  • No more than 1/2" of the Ethernet cable should be untwisted otherwise it will be susceptible to crosstalk.
  • Do not deform, do not bend, do not stretch, do not staple, do not run parallel with power cables, and do not run Ethernet cables near noise inducing components.

Saturday, June 26, 2010

Format Data Tanggal dan Waktu Pada SQL Server

SQL Server menggunakan format tanggal MM/dd/yyyy dan waktu hh:mm:ss seperti pada contoh perintah SQL berikut ini:

insert into test values ('888', 'Trisnadi Wijaya', '1:25:30 PM 12/30/2010')


Akan menghasilkan data seperti pada snapshot berikut:




Pada Kolom1 berisi 888, Kolom2 berisi Trisnadi Wijaya, dan Tanggal berisi 2010-12-30 13:25:30.000

Friday, June 25, 2010

Koneksi Visual Basic.Net ke MySQL

Untuk membuat kolaborasi antara VB.net dan MySQL diperlukan MySQL Connector (for .net tentunya) bisa di-download di MySQL Connector for .Net, dan jika sudah di-download silakan di-install.

Berikut adalah cara untuk menghubungkan antara VB.Net dengan MySQL:
1. Pilih menu Project lalu Add Reference kemudian cari MySql.Data lalu klik OK.


2. Pada bagian teratas dari halaman code form atau module ketikkan baris berikut: Imports MySql.Data.MySqlClient
Sekarang project VB.Net Anda telah terkoneksi dengan MySQL dan Anda dapat menggunakan code pemrograman seperti biasa untuk melakukan manipulasi pada database.

Software Aplikasi GUI untuk MySQL

HeidiSQL, sebelumnya dikenal sebagai MySQL-Front, adalah GRATIS dan klien open source yang dikembangkan oleh programmer Jerman Ansgar Becker dan beberapa kontributor lain dalam Delphi. Untuk mengelola database dengan HeidiSQL, pengguna harus login ke server MySQL lokal atau remote dengan mandat diterima, menciptakan sesi. Dalam sesi ini, pengguna dapat mengelola Database MySQL dalam MySQL server terhubung, memutuskan hubungan dari server jika sudah selesai. set fitur adalah cukup untuk database yang paling umum dan canggih, tabel dan operasi data rekam tapi tetap aktif dalam pembangunan untuk bergerak ke arah fungsionalitas penuh diharapkan dalam Frontend MySQL.

Tampilan HeidiSQL

Manufacturer: Ansgar Becker 
Price: FREE (donations accepted via PayPal) 
License: GNU General Public License 
Supported platforms: Windows 2000, XP, Vista, 7 (can be run on any Linux with Wine)

Thursday, June 24, 2010

Menambah Hari Pada Tipe Data Tanggal

Jika kita ingin mengetahui selisih hari di antara dua tanggal menggunakan DateDiff, sedangkan untuk menambah hari pada tanggal misalnya untuk mengetahui tanggal jatuh tempo pembayaran setelah 30 hari dari tanggal penjualan, gunakan fungsi DateAdd seperti format berikut:

DateAdd(DateInterval.Day, IntervalHari, TanggalAwal)

Penggunaan DateAdd hanya berfungsi jika menggunakan DateTimePicker saja. Tanpa DateTimePicker fungsi ini tidak dapat berjalan. Lalu bagaimana jika kita tidak menggunakan DateTimePicker? Selain menggunakan fungsi DateAdd kita dapat juga menggunakan DateTime.AddDays(Interval_Hari As Double), seperti pada contoh syntax berikut:

Dim awal, akhir As System.DateTime
Label1.Text = Now.Date
awal = Label1.Text
akhir = awal.AddDays(30)
Label2.Text = akhir


Syntax di atas akan menambah sebanyak 30 hari dari tanggal yang terdapat pada Label1 (berisi tanggal sistem pada hari ini). Perintah DateTime.AddDays dapat berjalan pada semua control baik label, textbox, atau datetimepicker.

Menghitung Jumlah Total Nominal Pada ListBox

Fungsi berikut untuk menghitung Total_Belanja pada ListBox:

Private Sub Hitung()
   Dim totalbelanja As Long
   totalbelanja = 0
   For t As Integer = 0 To ListBox1.Items.Count - 1
      totalbelanja = totalbelanja + Val(ListBox1.Items.Item(t))
   Next
   Label1.Text = totalbelanja
End Sub

Menghitung Selisih Hari Pada Tipe Data Tanggal

Bagaimana caranya jika kita ingin menghitung selisih hari (lamanya hari) terutama untuk aplikasi yang menghitung hari sebagai penentu biaya/harga seperti denda keterlambatan penyewaan buku, lamanya menginap di hotel, dll. Kita cukup menggunakan fungsi DateDiff yang ada pada VB dengan format penulisan sbb:

Dim hari As Long = DateDiff(DateInterval.Day, TanggalAwal, TanggalAkhir)

Sunday, June 20, 2010

Migrasi Data dari Berbagai Platform Database


Anda mengalami kesulitan ketika akan mengkonversi atau migrasi data dari berbagai platform database. Semua masalah tersebut terpecahkan dengan program ESF Database Migration Toolkit.

Saya akan memberikan panduan cara untuk mengkonversi data dari MySQL ke SQL Server 2000/2005 atau versi yang lebih tinggi:

1). Pada kotak dialog "Choose Data Source", pilih "MySQL Database", lalu isi nama server (default localhost), port (default 3306), nama pengguna (default-nya adalah root) dan password; Tekan "Refresh" untuk otomatisasi enumerasi semua database dari MySQL Server, pilih database yang ingin dipindahkan, kemudian klik "Next" untuk melanjutkan.

2). Pada kotak dialog "Choose a Data Destination" pilih "Microsoft SQL Server (Standard) " atau "Microsoft SQL Server ( OS Authentication)"; Isi nama server dimana SQL Server berada dan port server (default-nya adalah 1433, atau 1284 untuk SQL Server 2005 Express), plus, jika Anda ingin menawarkan sebuah username dan password ketika menggunakan "Microsoft SQL Server (Standard)". Tekan tombol "Refresh", program ini akan mencari semua database yang berada di SQL Server secara otomatis, Anda dapat memilih database secara langsung, atau menciptakan database baru di kolom "Database" lalu dikonversi. Klik "Next" untuk melanjutkan.

3). Pada kotak dialog "Select source Tables(s) & View(s)", program akan mendaftar semua tabel dan view dalam database MySQL, Anda dapat melihat pratinjau tabel data source melalui fungsi "Preview". Pilih tabel atau view yang sudah dipersiapkan untuk dikonversi. Di sini, Anda memiliki kesempatan untuk mengubah nama tabel tujuan di kolom "Destination". Ada pilihan "Overwrite Database" di bawah daftar (Perhatikan: Jika Anda memilih opsi ini, tujuan database SQL Server akan dihapus, dan semua data akan hilang!). Jika Anda ingin mengatur opsi leibh lengkap untuk konversi, klik tombol "..." di kolom "Transform".

4). Pada kotak dialog "Transform", ada beberapa pilihan untuk konversi. Anda hanya dapat menkonversi struktur tabel melalui pilihan "Copy Structure Only", atau centang "Copy Indexes"/"Copy Foreign Keys" untuk mengaktifkan / menonaktifkan MySQL copy index/foreign key ketika konversi. Pilihan "Transfer auto-increment" paling berguna untuk mengkonversi tabel MySQL dengan field auto-increment (misalnya: ID), kadang-kadang, ketika Anda menambahkan data ke tabel SQL Server dengan auto-increment, mungkin Anda akan menerima pesan seperti "Duplicable-keys ...", untuk mengatasinya Anda dapat menghilangkan centang opsi ini. Plus, Anda dapat mengubah tabel/kolom di pilihan "Table/Column Name" atau memberikan filter data (misalnya: [id]<100) di pilihan "Records Filter (WHERE)" (Jika Anda ingin bermigrasi semua data biarkan pilihan ini kosong atau 1=1). Dalam daftar "Field Map" Anda dapat memilih field tabel yang akan migrasi dan field name, type, allow null, size, precision, default value. Ketika semua selesai, klik "OK" untuk menyimpan pengaturan Anda.

5). Dalam kotak dialog "Execution", klik "Submit" untuk memulai konversi. Ketika konversi sedang berjalan, klik "Stop" untuk menghentikan konversi.

6). Untuk mengkonversi dari SQL Server 2000/2005 atau lebih tinggi ke MySQL, hanya memilih "SQL Server (Standard)" atau "Microsoft SQL Server (OS Authentication)" pada halaman "Choose a Data Source" dan pilih "MySQL Database" di halaman "Choose a Destination", pengaturan lainnya adalah sama seperti di atas.

Friday, June 18, 2010

Cara Membuat Favicon

Favicon (favorites icon atau sering disebut juga sebagai page icon) terletak tidak jauh dari address bar atau judul halaman sebuah web. Letaknya tepat di sebelah kiri tulisan halaman URL.

Contoh Favicon

Bagaimana caranya membuat favicon-nya? 
Untuk membuatnya, kita harus memiliki gambar yang akan dipakai untuk membuat favicon-nya. Jika sudah, berikut ini adalah langkah-langkahnya: 

1. Buat atau pilih sebuah gambar yang akan di jadikan sebagai favicon
2. Setelah itu anda harus mengubah bentuk gambar tersebut ke dalam bentuk gambar icon.
Anda dapat menggunakan tool Favicon Generator, silahkan kunjungi situs www.favicongenerator.com
3. Klik pada tombol Browse... 
4. Masukan gambar yang dibuat tadi untuk diubah menjadi format icon 
5. Klik pada tombol Generate Favicon.
6. Setelah proses selesai, klik pada Click Here to Download your favicon
7. Save file gambar icon ke komputer anda. 
8. Selesai. Sekarang Anda sudah mempunyai favicon pada situs web.

Bagi anda yang masih menggunakan browser IE6, favicon anda tidak akan langsung terlihat, coba di bookmark dulu alamatnya. Berbeda jika anda menggunakan browser firefox, opera dan yang lainnya, favicon anda sudah langsung dapat di nikmati.

Wednesday, June 9, 2010

JOIN: Perintah SQL yang Powerful

Ketika membuat sebuah program aplikasi yang berhubungan dengan dua atau lebih tabel sebagai akibat dari adanya normalisasi basis data, gunakan perintah JOIN yang terdapat pada SQL daripada harus membuat source code yang rumit untuk membaca data.

Berikut ini adalah contoh dari perintah JOIN:
SELECT a.tanggal, b.kode_barang, b.qty, c.nama_barang, c.harga FROM (tblheaderjual AS a JOIN tbldetailjual AS b ON a.no_invoice = b.no_invoice) JOIN tblbarang AS c ON b.kode_barang = c.kode_barang WHERE b.kode_barang='00001'

Penjelasan:
Perintah SQL untuk menampilkan data dengan menghubungkan 3 tabel yang berbeda, yaitu tblheaderjual, tbldetailjual, dan tblbarang khusus barang dengan kode '00001'.

Tuesday, June 8, 2010

Membuat Label Waktu Berdetik

Jika Anda ingin menambahkan sebual label waktu pada form yang dapat berdetik, maka berikut ini syntax-nya:

Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Format(Now, "hh:mm:ss")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub

End Class

Penjelasan:
Timer1.Enabled = True berfungsi untuk membuat timer berdetik. Jika enabled-nya dibuat false, maka timer akan berhenti.
Label1.Text = Format(Now, "hh:mm:ss") untuk menampilkan waktu sekarang

Monday, June 7, 2010

Menghitung Jumlah Total Nominal Pada Listview

Jika Anda ingin menghitung total pembayaran dari subtotal pembelian yang dilakukan oleh pelanggan dengan menjumlahkan salah satu kolom dari Listview. Misalkan kolom yang akan dihitung totalnya berada di kolom ke-4 (kolom paling kiri berindex nol), maka syntax-nya sebagai berikut:

Dim total as integer
For i As Integer = 0 To Listview1.Items.Count - 1
total = total + listview1.Items(i).SubItems(3).Text
Next
'Tampilkan hasil dari Total Bayar
TxtTotal.text = total

Keterangan:
i adalah posisi baris pada listview
Listview1.Items.Count untuk menghitung jumlah baris data pada listview
Subitems (3) merujuk pada kolom ke-4 dari listview (index kolom = posisi kolom - 1)

Tuesday, June 1, 2010

Mengisi ComboBox dengan Mengambil Data dari SQL Server

Anda ingin mengisi combobox dengan data yang diambil dari SQL Server, berikut ini adalah syntax-nya:

Imports System.Data.SqlClient
-----
Dim cn As New SqlConnection("Data Source=ORACLE\SQLEXPRESS;Initial Catalog=Kampus;Integrated Security=True")
Dim comm As New SqlCommand("", cn)
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Dim dr As SqlDataReader
-----

cn.Open()
comm.Connection = cn
comm.CommandType = CommandType.Text
comm.CommandText = "Select * from tbljurusan order by kode"
dr = comm.ExecuteReader
If dr.HasRows Then
   While dr.Read()
        ComboBox1.Items.Add(dr.Item("kode") + " ---> " + dr.Item("jurusan"))
   End While
        End If
dr.Close()
cn.Close()
 

Blogger news

About Me

Palembang, Sumatera Selatan, Indonesia
Seorang yang ingin terus belajar.