Kamis, 27 Oktober 2011

Source Code Sederhana Cut-Copy-Paste Pada Visual Basic

Source code berikut untuk memfungsikan Cut-Copy-Paste pada Visual Basic. Sama halnya dengan konsep Cut-Copy-Paste yang sudah sering kali kita gunakan saat menggunakan Windows, meskipun source code berikut digunakan untuk Cut-Copy-Paste pada textbox alias pada teks/karakter bukan pada file.
Buat 1 project dengan :
1 Form
1 TextBox
3 CommandButton
Source code pada Form : 
01'copy
02Private Sub Command1_Click()
03    Clipboard.SetText Text1.SelText
04End Sub
05 
06'paste
07Private Sub Command2_Click()
08    Text1.SelText = Clipboard.GetText()
09End Sub
10 
11'cut
12Private Sub Command3_Click()
13    Clipboard.SetText Text1.SelText
14    Text1.SelText = ""
15End Sub
Untuk lebih jelasnya Download Source Code Sederhana Cut-Copy-Paste Pada Visual Basic

Teks Berjalan Pada Caption Form

Source code berikut untuk membuat teks berjalan pada caption form.
Yang diperlukan :
1 Form
1 Timer (set interval = 200)
Source code pada Form :
Dim teksJalan As String
Private Sub Form_Load()
teksJalan = "Teks ini berjalan pada caption Form. "
End Sub
Private Sub Timer1_Timer()
a = Left(teksJalan, 1)
c = Len(teksJalan)
b = Right(teksJalan, c - 1)
teksJalan = b + a
Form1.Caption = teksJalan
End Sub Download Source Code

Mengatasi Error Pada Saat Membuat Report Dengan Crystal Report 8.5 Dan MySQL ODBC 3.51

Beberapa hari ke belakang sempat saya membuat program dengan Visual Basic 6 dan database MySQL dan ODBC nya versi 3.51. Membuat report nya dengan Crystal Report 8.5. Pada saat membuat report dengan hanya 1 tabel saja semuanya berjalan lancar, tapi saat membuat report dengan banyak tabel, muncullah pesan error yang membingungkan, error-nya kaya begini “you have an error in your SQL syntax. bla bla bla. error detected by database dll.”
Nah loh, kenapa lagi itu. Googling semalaman, dan ternyata ketemu kalo MySQL ODBC tidak mendukung syntax INNER atau OUTER JOIN yang dibuat pada Crystal Report 8.5 dengan banyak tabel. Solusinya adalah menambahkan “SQL2OuterJoin” pada registry Crystal Report.
Berikut langkah-langkah nya :
  1. Buka registry editor ( Start > Run > ketik “regedit” > tekan “Enter” )
  2. Cari registry : HKEY_CURRENT_USER\Software\Seagate Software\Crystal Reports\DatabaseOptions\ODBC
  3. Buat key baru dengan cara, klik kanan pada ODBC, pilih New > Key.
  4. Beri nama OuterJoin
  5. Di dalam key OuterJoin buat string value baru, klik kanan pilih New String Value.
  6. Beri nama SQL2OuterJoin
  7. Klik kanan pada string value SQL2OuterJoin, pilih Modify.
  8. Isikan : libmyodbc3
  9. Selesai.
Dengan cara diatas kini anda bisa membuat report dengan banyak tabel pada Crystal Report 8.5

source : pregool.com

Connection String


Connection String Untuk Access 2000-2003

Standard security
1Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;
With database password
This is the connection string to use when you have an access database protected with a password using the Set Database Password function in Access. 
1Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;
Workgroup (system database)
1Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;
Workgroup (system database) specifying username and password
1Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;
DataDirectory functionality
1Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myDatabase.mdb;User Id=admin;Password=;
Network Location
1Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\serverName\shareName\folder\myDatabase.mdb;User Id=admin;Password=;   

source: connectionstrings dot com

Connection String Untuk Access 2007

Standard security
1Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;
With database password
This is the connection string to use when you have an Access 2007 database protected with a password using the “Set Database Password” function in Access.
1Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Jet OLEDB:Database Password=MyDbPassword;
DataDirectory functionality
1Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\myAccess2007file.accdb;Persist Security Info=False;

source: connectionstrings dot com

Menghitung selsih tanggal

Source code visual basic 6 berikut untuk menghitung selisih dari 2 tanggal berbeda. Misal jika input tanggal awal “1 Januari 2009″ dan tanggal akhir “1 Maret 2010″, maka output yang keluar adalah “1 Tahun 2 Bulan”.
Buat 1 project baru dengan :
1 Label
1 CommandButton
2 DTPicker (Jika tidak ada, tekan CTRL+T, dan ceklis “Microsoft Windows Common Control-2 6.0″)
Source code :

Private Sub Command1_Click()

Dim Tahun As Integer, Sisa As Integer
Dim SelisihBulan As Integer
On Error GoTo Pesan
SelisihBulan = DateDiff("m", DTPicker1.Value, DTPicker2.Value)
  Tahun = SelisihBulan \ 12
  Sisa = SelisihBulan Mod 12
  Label1.Caption = "Selisih : " & Tahun & " Tahun " & Sisa & " Bulan"
  Exit Sub
Pesan:
  MsgBox "Tipe tanggal salah!", vbCritical, "Error Tanggal"
End Sub

Senin, 24 Oktober 2011

Hitung selisih hari dengan VB.net 2010

Em aku mau berbagi Tutorial lagi ne gan sis yang akan dibahas adalah bagaimana cara menghitung selisih hari pada tanggal dengan .net versi Visual studio 2010. Banyak sekali Program Aplikasi yang kita buat membutuhkan perhitungan seperti ini misalkan antara tanggal 1 Januari – 5Februari berapa lama selisih harinya?
Jadi mari kita langsung kepada pembuatan Programnya :
Pertama Siapkan 3 Buah Label , 3 Buah Textbox dan 1 Buah Button Atur Propertiesnya seperti gambar di bawah ini :
Keterangan : jadi pada TextBox Tanggal Sebelumnya namakan txt_sebelumnya dan Biarkan Textnya Kosong
TextBox Tanggal sekarang namakan txt_sekarang dan Biarkan Textnya Kosong
TextBox Selisih Hari atur propertis name menjadi txt_selisih dan Biarkan Textnya Kosong
Lalu Klik dobel pada Form tersebut (Anda bebas memberi nama Form ini) dan ketikkan kode di bawah Public Class
Public Class Form_selisih_hari
Dim hari As Integer
'dim ini sebagai deklarator
Setelah itu masukan Rumus ini di bawah Form_selisih_hari Load atau klik dobel pada Form tersebut:
'Fungsi ini untuk menampilkan tanggal secara otomatis pada saat program di jalankan
'Perintah di bawah untuk menampilkan Tanggal Bulan dan tahun 5 Hari sebelum tanggal sekarang pada komponen txt_sebelumnya
txt_sebelumnya.Text = Format(System.DateTime.FromOADate(Today.ToOADate - 5), "dd MMMM yyyy")
'Perintah di bawah untuk menampilkan tanggal sekarang pada komponen txt_sekarang
txt_sekarang.Text = Format(Today, "dd MMMM yyyy")
Lalu Klik pada Button Hitung Selisih dan Masukan Kode Berikut :

hari = DateDiff(DateInterval.Day, CDate(txt_sebelumnya.Text), CDate(txt_sekarang.Text))        
If Format(hari) = 0 Then

txt_selisih.Text = "0" 'Jika hasil selisih hari yang di peroleh 0

Exit Sub

ElseIf Format(hari) < 0 Then 'Jika hasil selisih hari yang di peroleh lebih kecil dari 0            
txt_selisih.Text = "0"

Exit Sub

ElseIf Format(hari) > 0 Then 'Jika hasil selisih hari yang di peroleh lebih besar dari 0            
txt_selisih.Text = Format(hari, "#,#")

End If

End Sub 
 
 
Hasil Running :
  


Contoh lain

.Net merupakan sebuah pemrograman yang amatt menyenangkan dan powerfull. Di sini saya kan bagikan cara sederhana menghitung selisih tanggal pada datetimepicker dengan tanggal sekarang. Pemrograman ini di rancang dengan mengguakan Visual Studio 2010
Secara Logika Penjelsannya ada pada Rumus berikut :
Textbox1.text = Now – DateTimePicker1.value
Example
Now = Juni 28, 2011 00:05:00 AM
DateTimePicker1.value = Juli 10, 2011
Akku Ingin mendapatkan Textbox1.text = Format (Hari, Jam, Menit)
Oke Lets Go
Segera Rancang Interface Kita seperti berikut ini :
Form Tersebut terdiri dari 2 Label 1 DateTimePicker, 1 Buton dan 1 TextBox Atur Propertisnya seperti pada Gambar.
Klik DObel pada Button lalu masukan Kode berikut ini :
Dim T As TimeSpan = DateTimePicker1.Value - Now
TextBox1.Text = T.Days & " Days " & T.Hours & " Hours " & T.Minutes & " Minutes "
 
Mudah Bukan . Seoga bisa membantu anda
Selamat Berkreasi dan bila ada yang perlu di tanyakan silahkan Kirim pesan ke saya




Nyari selisih Tanggal PHP

Teman sy mo tanya ttg selisih 2 buah tanggal dmn terdiri 3 buah textfield dimana
tgl1 merupakan tanggal yang diambil dari sistem.
tgl2 merupakan tanggal yang diambil dari database
datn tgl 3 merupakan hasil pengurangan

Untuk fungsi pengurangan saya menggunakan fungsi gregoriantojd.
Tp hasil yang saya dapatkan selisihnya adalah 0

code:
<?php

include 'koneksi.php';
$tgl1=date('Y-m-d');


$tgl2 = $_POST['tgl2'];
$selisih = $_POST['selisih'];

$SQL = "SELECT * FROM tgl";
$QUERY = mysql_query($SQL);
$result = mysql_fetch_array($QUERY);

$pecah1 = explode("-", $tgl1);
$date1 = $pecah1[2];
$month1 = $pecah1[1];
$year1 = $pecah1[0]; 

$pecah2 = explode("-", $tgl2);
$date2 = $pecah2[2];
$month2 = $pecah2[1];
$year2 =  $pecah2[0]; 

$jd1 = GregorianToJD(strtotime($month1), strtotime($date1), strtotime($year1));
$jd2 = GregorianToJD(strtotime($month2), strtotime($date2), strtotime($year2)); 
$selisih = abs($jd2 - $jd1);

?>
<html>
<head>
</head>
<body>
<form name="form1" method="post" action="">
  <input type="text" name="tgl1" value="<?php echo $tgl1 ?>">
  <input type="text" name="tgl2" value="<?php echo $result['date']; ?>">
  <input name="selisih" type="text" id="selisih" value="<?php echo $selisih ?>"> 
</form>

</body>
</html>

kira2 dari script diatas apakah ada yg salah ? mohon infonya

Thx...

mencari selisih tanggal VB 6

Untuk mencari selisih dari dua buah tanggal tidaklah sulit, karena dalam visual basic telah disediakan fasilitas untuk melakukan hal tersebut dengan menggunakan fungsi " datediff ", yaitu sebuah fungsi yang digunakan untuk mendapatkan selisih dari dua buah tanggal. Dari fungsi dafediff kita bisa mendapatkan selisih hari, bulan dan tahun dari dua buah tanggal.

Cara penggunaan dari fungsi ini adalah sbb:

dim hari, bulan, tahun

'Untuk mencari selisih hari
hari=DateTime.DateDiff("d", CDate(Text1.Text), CDate(Text2.Text))

'Untuk mencari selisih bulan
bulan = DateTime.DateDiff("m", CDate(Text1.Text), CDate(Text2.Text))

'Untuk mencari selisih tahun
tahun = DateTime.DateDiff("yyyy", CDate(Text1.Text), CDate(Text2.Text))


Dalam contoh code diatas yang membedakan dari tiap kegunaannya adalah fungsi "d,m dan yyyy", dimana ketiganya mewakili untuk hari atau day (d), bulan atau month (m).

Dalam kode diatas, terdapat satu fungsi yang berfungsi untuk meng convert mengubah tipe data dari string ke tipe tanggal, yaitu fungsi CDate .

Kode diatas dapat kita letakkan pada prosedur command_click atau bisa juga diletakkan pada tempat lain.

Sabtu, 15 Oktober 2011

semoga bemanfaat
Posted 15 October 2009 - 10:24 AM
View Postfirebolt, on 25 Mar, 2009 - 11:14 PM, said:
Welcome DIC coders
I will show you how to create a simple stopwatch for visual basic 6 beginners. This stopwatch consists of 3 labels called Label1, Label2, Label3 and 2 buttons called btnSart and btnExit.


1. Create 3 labels named Label1, Label2 and Label3.
2. Change the text of these labels to the number 0.
3. Create a Start/Stop button called btnStart.
4. Create an Exit button called btnExit.
5. Finally, create a timer called tmrTime. Make sure you change the timer interval to 1000 to represent 1 second. This can be placed anywhere in the form as it does not interfere with the design/object.

Then we start our coding. As long as you have labelled everything correctly, you can simple just type all this in without going back and referring to each component.

We will first code the button Start/Stop. This code means if the timer doesnt start automatically, this starts it.
1Private Sub btnStart_Click()
2If tmrTime.Enabled = False Then
3tmrTime.Enabled = True
4Else
5tmrTime.Enabled = False
6End If
7End Sub


Next we will code the timer tmrTime. This basically means the timer will gradually add on 1 second and when it reaches 60 secs, the minute label will start. This is the same for the hour label.
01Private Sub tmrTime_timer()
02Label3.Caption = Val(Label3.Caption) + Val(1)
03If Label3.Caption = 60 Then
04Label2.Caption = Val(Label2.Caption) + Val(1)
05Label3.Caption = 0
06ElseIf Label2.Caption = 60 Then
07Label1.Caption = Val(Label1.Caption) + Val(1)
08Label2.Caption = 0
09End If
10End Sub


Now we will address the issue of the form. This means when the form loads, the timer will not start yet until you click the start/stop button.
1Private Sub Form_Load()
2tmrTime.Enabled = False
3End Sub


Finally we code the Exit button. This just exits the program.
1Private Sub btnExit_Click()
2Unload Me
3End Sub


Now the form should look similar to the attached image. You can also change the name of the form and give the hours, minutes and second a name label.

Thanks for viewing this tutorial.

Membuat Program Stopwatch Sederhana dengan Visual Basic 6.0

Pasti Anda tau dengan yang namanya stopwatch, stopwatch adalah alat pengukur waktu. Pada postingan ini saya akan membahas pembuatan program stopwatch.


Pada program ini pengukur waktu yang digunakan dalam satuan menit,detik dan milidetik. Rancanglah Form seperti tampilan gambar diatas.
Source Code dari program diatas :
———————————————————————————————-
Private Sub CmdStart_Click()
Xmili.Caption = “00″
xdetik.Caption = “00″
xmenit.Caption = “00″
Timer1.Enabled = True
CmdStart.Enabled = False
CmdStop.Enabled = True
End Sub
Private Sub CmdStop_Click()
Timer1.Enabled = False
CmdStart.Enabled = True
CmdStop.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
CmdStop.Enabled = False
End Sub
Private Sub Timer1_Timer()
Xmili.Caption = Val(Xmili.Caption) + 1
If Len(Xmili.Caption) = 1 Then Xmili.Caption = “0″ & Xmili.Caption
If Xmili.Caption = “60″ Then
Xmili.Caption = “00″
xdetik.Caption = Val(xdetik.Caption) + 1
If Len(xdetik.Caption) = 1 Then xdetik.Caption = “0″ & xdetik.Caption
End If
If xdetik.Caption = “60″ Then
xdetik.Caption = “00″
xmenit.Caption = Val(xmenit.Caption) + 1
If Len(xmenit.Caption) = 1 Then xmenit.Caption = “0″ & xmenit.Caption
End If
End Sub
———————————————————————————————-

Post A simple timer

In this tutorial we'll be making a simple timer that prints off a line every second into a ListBox.
--------------------------------------------------------------

 GUI (Layout)Here's my GUI (layout):


----------------------------------------------------------------
What you need to add:

4 Command Buttons:

With the following names/captions:

#1 Command Button:
Name: cmdStart
Caption: Start Timer

#2 Command Button:
Name: cmdStop
Caption: Stop Timer

#3 Command Button:
Name: cmdClear
Caption: Clear Text

#4 Command Button:
Name: cmdExit
Caption: Exit

1 ListBox
With:

Name:lstCount
Caption: (None)

1 Timer
With:

Name: tmrTimer
Caption: (None)

----------------------------------------------------------------
CODE:
Add this code to General Declarations:
Dim Response As Integer
Dim mintCount As Integer
Then this:

Private Sub cmdClear_Click()
lstCount.Clear
End Sub

Private Sub cmdExit_Click()
Response = MsgBox("Exit Program?", vbInformation + vbYesNo, "Are you sure?")
If Response = vbYes Then
Unload Me

ElseIf Response = vbNo Then
Me.Refresh

End If

End Sub

Private Sub cmdStart_Click()



mintCount = 0

Cls

tmrTimer.Enabled = True



End Sub



Private Sub cmdStop_Click()



tmrTimer.Enabled = False



End Sub





Private Sub tmrTimer_Timer()



mintCount = mintCount + 1

lstCount.AddItem "Timer fired again. Count = " & mintCount



End Sub
---------------------------------------------------------------
CODE EXPLANATION:

Private Sub cmdClear_Click()
lstCount.Clear
End Sub
This just means whenever you click the "Clear Text" button, the ListBox will be cleared of all text.

---------------------------------------------------------------
Private Sub cmdExit_Click()
Response = MsgBox("Exit Program?", vbInformation + vbYesNo, "Are you sure?")
If Response = vbYes Then
Unload Me

ElseIf Response = vbNo Then
Me.Refresh

End If

End Sub
What this does is whenever you click the "Exit" button, it asks you if you REALLY want to exit. If YES then it will exit, if NO then it will jsut go back to the previous screen.

----------------------------------------------------------------
Private Sub cmdStart_Click()



mintCount = 0

Cls

tmrTimer.Enabled = True



End Sub
This code makes the timer start every time you click the "Start Timer" button.

----------------------------------------------------------------
Private Sub cmdStop_Click()



tmrTimer.Enabled = False



End Sub
Very simple code that stops the timer when you click the "Stop Timer" button.

----------------------------------------------------------------
Private Sub tmrTimer_Timer()



mintCount = mintCount + 1

lstCount.AddItem "Timer fired again. Count = " & mintCount



End Sub
Ok this is a tad harder then the rest of the codes...
"mintCount" was dimmed as an integer in the "General declarations" section. With this said, the code means that every time the mintCount function is used, it adds +1 onto itself.

lstCount.AddItem "Timer fired again. Count = " & mintCount

Means that every time the mintCount is used, it adds the line "Timer fired again. Count = ?" Into the ListBox.
(The "?" means the number that the timer is up to)

----------------------------------------------------------------

Well this is the end of my Tutorial. Thanks for taking the time to read my tutorial.



This tutorial made completely by me, Travy92.
Special thanks the Tcm9669 for the screenshot program.

I've enclosed the sample:


Attached Files
Last edited by Jordan; 09-10-2007 at 05:18 AM.

Selasa, 11 Oktober 2011

Yang mau widget keren buat dipajang diBlog

1. Copy the widget code and paste it on your blog or web page (in HTML View). For installation guide, click here.. if you like this widget, click like button and share it with your friends on facebook..thanks ;)

Corner left - copy this code if you want to put it on bottom left position:


Sidebar - copy this code if you want to put it on your sidebar:


2. Corner left - copy this code if you want to put it on bottom left position:


Sidebar - copy this code if you want to put it on your sidebar: