http://poj.org/problemlist
Senin, 14 November 2022
Sabtu, 24 Agustus 2019
Soal-Soal Algoritma & Pemrograman Fungsi Rekursif
- Buat program yang mengandung fungsi untuk menghitung perkalian. Nama fungsi : kali(a, b). Input : a dan b. a dan b bilangan bulat. Outputnya adalah hasil perkalian a dengan b.
- Buat program yang mengandung fungsi untuk menghitung faktorial. Nama fungsi : faktorial(n). Input : n. n adalah bilangan bulat positif. Outputnya adalah hasil dari fakrotial n.
- Buat program yang mengandung fungsi untuk menghitung permutasi. Nama fungsi : permutasi(a, b). Input : a dan b. a dan b adalah bilangan bulat positif. Outputnya adalah hasil dari permutasi a dan b.
- Buat program yang mengandung fungsi untuk menghitung kombinasi. Nama fungsi : kombinasi(a, b). Input : a dan b. a dan b adalah bilangan bulat positif. Outputnya adalah hasil dari kombinasi dan b.
- Buatlah program untuk mencari berapa angka ke-n dari deret Fibonacci. Nama fungsi : fibonacci(n). Input : n. n adalah urutan angka / no. urut / suku ke-n, yang ada dalam deret Fibonacci. Output : angka dari dalam deret Fibonacci sesuai dengan urutan yang diinput.
Senin, 29 Juli 2013
Cara Mengecek atau Memeriksa Versi MDAC
MDAC ini menjadi penting saat program aplikasi akan didistrbusikan (diinstall) ke komputer klien. Karena jika di komputer klien tidak terdapat MDAC yang tepat versinya, program aplikasi bisa jadi tidak dapat bekerja dengan sempurna.
Langkah-langkah untuk memeriksa MDAC di suatu komputer adalah melalui registry dengan langkah sebagai berikut :
Informasi versi yang ditemukan dalam kunci berikut:
- Pada Mulai menu, klik Menjalankan.
- Dalam Terbuka kotak teks, ketik regedit kemudian klik Oke; ini mulai Peninjau Suntingan Registri.
- Di panel navigasi, drill-down lintasan berikut:HKEY_LOCAL_MACHINE\Software\Microsoft\DataAccess
- Di panel rincian, lihat di Nama kolom untuk FullInstallVer dan Versi. Masing-masing kunci ini akan memiliki informasi versi yang sesuai dalam Data kolom.
- Setelah selesai, klik Keluar pada Registri menu untuk menutup Registry Editor.
Untuk dapat men-download MDAC silahkan klik link donwload MDAC ini.
Catatan : Pada saat kita menginstall software database system buatan Ms, biasanya MDAC sudah diikutsertakan dalam instalasi!
Rabu, 08 Mei 2013
Perbedaan New Line dan Carriage Return (Difference of NL and CR)
http://stackoverflow.com/questions/3307747/difference-between-newline-and-carriage-return-r
Selasa, 31 Januari 2012
Soal Latihan Algoritma dan Dasar-dasar Pemrograman
- Buatlah algoritma / program untuk menghitung volume sebuah silinder yang memiliki radius 12,5 cm dan tinggi 10 cm.
- Buatlah algoritma / program untuk menghitung luas segitiga jika memiliki alas 1,2 m dan tingginya 1100 mm.
- Buatlah program untuk menhitung energi kinetik suatu benda yang jatuh bebas dari lantai 5 sebuah gedung. Setiap lantai rata-rata memiliki ketinggian 10 m. Nilai percepatan grafitasi adalah 10 m/detik. Petunjuk : energi potensial = energi kinetik. energi potensial = masa x gravitasi x ketinggian awal. energi kinetik = 0,5 x massa x kecepatan akhir2.
- Sebuah rangkaian listrik terdiri dari tiga buah resistor yang dirangkai secara paralel. Besarnya hambatan masing-masing resistor adalah 10 ohm, 25 ohm, 12 ohm. Rangkaian terhubung pada sumber daya listrik yang memiliki tegangan 100 volt. Hitunglah total nilai resistansi ekivalen rangkaian resistor tersebut dan hitung pula besarnya arus yang mengalir di dalam rangkaian. Total nilai resistensi adalah kebalikan total penjumlahan dari 1/R tiap resistor. Sedangkan besarnya arus yang mengalir sama dengan besarnya tegangan dibagi total nilai resistansi ekivalen rangkaian resistor.
- Sebuah toko menjaul barang ABC dan DEF. Harga kulakan ABC adalah Rp 200.000,00 dan dijual 15% lebih tinggi dari harga kulakannya.Barang DEF dijual dengan harga Rp 300.000 dan harga kulakannya 8% lebih rendah dari harga penjualan. Pada awal bulan pemilik toko kulakan ABC sebanyak 200 buah, dan DEF 100 buah. Pada akhir bulan semua barang habis terjual. Hitunglah keuntungan tiap barang, keuntungan semua barang dan hitung pula keuntungan bersih jika dipotong pajak sebesar 10%
Kamis, 21 April 2011
Masalah pada Penamaan VB.Net, Database SQL Server dan Access
Berdasakan pengalaman dari dulu, bahwasannya membuat suatu nama (misal nama file, nama prosedur, nama tabel, dan nama-nama lainnya) tidak boleh menggunakan SPASI menjadi aturan baku yang tidak bisa diganggu gugat. Ternyata kemarin mendapatkan problem karena ada nama tabel yang memakai spasi!!!
Gara-garanya adalah tabel tersebut sudah dibuat sangat lama (mungkin waktu masih super bego) kemudian digunakan lagi dalam membuat program VB.Net yang mengakses database... alhasil selama tiga hari mencari-cari penyebab masalah tidak bisanya data disimpan di dalam database tanpa menggunakan perintah SQL "insert" secara eksplisit (melalui dataset). Nah setelah nama tabelnya diganti (spasinya dihilangkan), barulah programmnya berjalan dengan benar.
Kesimpulan :
Jika ingin membuat nama, nama apa saja, nama file kek, nama database kek, nama class kek... jangan menggunakan SPASI walaupun sistem operasi Windows dan aplikasi-aplikasinya mendukung pemakaian spasi untuk penamaan. Gunakanlah garis bawah (underscore) sebagai pengganti spasi, atau dapat juga menggunakan cara penulisan punuk Onta (Camel text) Contoh : Hitung Total() diganti dengan Hitung_Total() atau HitungTotal()
Rabu, 29 Desember 2010
Trik Membuat Jeda / Penangguhan Waktu (Delay) pada Visual Basic
Public Sub jeda (ByVal detik as Integer)
Dim awal as date = Now()
While (DateDiff("s", awal, Now()) <= detik)
'do nothing
End While 'diganti Wend jika pakai VB6
End Sub
Selasa, 09 November 2010
Me-refresh DataReport pada VB 6
Yup, memang tidak ada kaitannya dengan judul. Tapi si penagih hutang lalu bertanya mengenai cara merefresh tampilan pada DataReport. Soalnya contoh yang saya beri beberapa waktu yang lalu tidak lengkap (sorry... hehehe).
Oh ya, DataReport merupakan fasilitas yang sudah ada di dalam Visual Studio 6. Sesuai namanya, DataReport digunakan untuk membuat laporan / report yang akan dicetak melalui printer.
DataReport merupakan alternatif untuk membuat laporan jika kita tidak memiliki program CrystalReport yang lebih populer.
Berikut source code VB 6 untuk memperbarui / me-refresh tampilan pada DataReport :
Private Sub btnLaporan_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
DataEnvironment1.rsCommand1.Open
DataEnvironment1.rsCommand1.Requery
DataReport1.Refresh
DataReport1.Show
DataEnvironment1.rsCommand1.Close
End Sub
Nah, berarti utang saya sudah lunas too... eh belum ya.. hihihi
Kamis, 17 Juni 2010
Membuat Form Login DASAR pada VB 6 Menggunakan Ms-Access 97 dan Komponen Data (DAO)
- Buat database menggunakan Ms-Access 97 atau add-in Visual Data Manager
- Buat tabel nama Users yang terdiri dari field nama dan password lalu isi datanya
- Buka VB 6 IDE kemudian buat form seperti pada gambar di bawah
- Tambahkan komponen Data lalu sembunyikan sehingga tampilan form seperti pada gambar sebelah kiri

- Setelah mengubah properti Connection, DatabaseName, dan RecordSource pada komponen Data1 kemudian buat program seperti di bawah ini
Private Sub Command1_Click()
Dim berhasil As Boolean
Data1.Recordset.MoveFirst
Do While Not Data1.Recordset.EOF
If Data1.Recordset.Fields(0) = Text1.Text And _
Data1.Recordset.Fields(1) = Text2.Text Then
berhasil = True
Exit Do
End If
Data1.Recordset.MoveNext
Loop
If berhasil Then
MsgBox ("Login berhasil")
Else
MsgBox ("login gagal")
End If
End Sub
Private Sub Command2_Click()
End
End Sub
- Selesai
Selasa, 15 Juni 2010
Jabaco : VB 6 dengan Kemampuan Java???
Dengan jantung yang berdebar-debar namun tidak berharap sesuatu yang bisa membuat hati meloncat... dikliklah link tersebut... jreeennggggg... eh ngga ding... lha wong internetnya ngos-ngosan... sabarrrr mass... seperti sedang jalan bersama putri solo pakai kebaya di jalan yang berbatu-batu dan menanjak... welehhhh... cape dehhhh
Setelah situsnya terbuka namanya www.jabaco.org, lalu kubaca dengan terbata-bata seperti anak kecil yg baru belajar baca (maklum isi situsnya pake bahasa bule Inggeris)... eh baca kok terbata-bata ya? terbata-bata kan kalo bicara ya?? au ah gelap!!! kembali ke leeppp toooppppp
Karena masih ga mudeng... mungkin karena bahasa Inglishna yang ngetik orang Jerman jadi rada-rada gimana gituh! (yang bikin Jabaco tu orang Jerman asliiii bukan jejer kauman :p) akhirnya tanya mbah Gugel... sama simbah dikasih banyak petunjuk... ngikutin yang pertama masih ga manjur... kedua samaaa hasilnyaaa... ketiga.... blehhhhh
Gue coba donlot ajah... prikitiew... kok ga ada versi finalnya ya? beta semua... biarin dah mumpung gratis... hmm kudu subscribe... biarin juga dah... soalnya biar dapet lisensi gratisannya.
Donlot selesai, langung diinstol tu Jabaco. Sembari instolnya jalan, ngikutin petunjuk mbah Gugel yang ke... wah ini baru aku ngertiiiii (dasar telmi <-- ngatain diri sendiri). Buru-buru ku jalankan Jabaco yang sudah selesai diinstol, buat program jurus dasar pasang Label, Textbox, Command button. Buat event handler Command1_Click() <--- VB 6 banget gitu loh. Ketik MsgBox(Text1.Text). Intellisensenya boleh juga. Lalu Run... rada lama keluar form-nya. Jalan normal.... Terusssss coba bikin file .exe-nya... Jadi! terussssss langsung dobel klik tuh file .exe-nya.... Waaa... di Form-nya nongol icon secangkir kopi panas... Java!!!
Jabaco dibuat karena pengemar fanatik VB 6.0 merasa dikesampingkan oleh Bill gates (nah lo) akhirnya mereka membuat sendiri bahasa pemrograman yang mirip VB 6.0 tapi dijalankan menggunakan JVM!!! (eh ngemeng-ngemeng JVM tu singkatan Java Virtual Machine).
Source code Jabaco yang dikompilasi menjadi byte-code Java!!! Lalu bisa dijalankan di semua platform yang mendukung Java.... wuiiii... coba gue punya Linux... bisa dicoba tuh... eh untuk hape bisa ga ya? Mudah-mudahan Jabaco terus berkembang-bang-bang... Jadi gue ga puyeng lagi pake Netbean yang.... ehem! uhuk! uhuk! (emang lagi batuk beneran lhooo) Cukup bikin program mirip VB 6 bisa dijalankan dimana saja.... assyyiikkk beeiiibeeehhh
Eh hampir lupa karena Jabaco jalan di JVM (JRE) jadi mendukung OOP atawa pemrograman berorientasi objek. Satu lagi... Jabaco ga bisa jalan di Vista atawa 7 bisanya di XP (doang?), Linux, Unix dan OS yang support Java lah yaow!
Kamis, 27 Mei 2010
Membuat Form Dapat Dicoret-coret dengan Mouse pada VB 6.0
Pada form tambahkan Command button setelah itu ketik program berikut :
Private Sub Command1_Click()
Form1.Cls
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form1.CurrentX = X
Form1.CurrentY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then 'jika tombol kiri diklik
Line (Form1.CurrentX, Form1.CurrentY)-(X, Y)
End If
End Sub
Gampang to??? diambil dari http://visualbasic.freetutes.com tanpa ijin (waduh!!! eh buat belajar ga pa pa to???)
Senin, 17 Mei 2010
Membuat Bilangan Acak Pada Visual Basic, C++, Java, JavaScript, PHP
VB / VB.Net / VBS / VBA :
Dim Acak as Integer
Dim Awal as Integer = 1
Dim Akhir as Integer = 10
Randomize()
Acak = CInt( Int( ( Akhir - Awal + 1 ) * Rnd() + Awal ) )
C++ :
#include #include #include using namespace std; int main() { srand((unsigned)time(0)); int acak; acak = (rand()%akhir)+awal; }
Java (updated) :
import java.util.Random;
public final class AcakAcak {
public static void main(String... aArgs){
int awal = 1, akhir = 10, hasil;
Random acak = new Random();
for (int i=1; i<=5; i++){
hasil = (int)((akhir - awal + 1) * acak.nextDouble() + awal);
System.out.println(hasil);
}
}
}
JavaScript :
var awal = 1;
var akhir = 10;
var acak = Math.floor( ( akhir - ( awa - 1 ) ) * Math.random() ) + awal;
PHP :
$awal = 1;
$akhir = 10;
srand(time());
$random = ( rand() % $akhir ) + $awal;
Selasa, 13 April 2010
Out of The Box!!!
Dim I as Integer
I = 1
While I < 1
Text1.Text = "1, 2, 3, 4, 5, 6, 7, 8 , 9, 10"
I = I + 1
Wend
Sementara teman-temannya umumnya membuat program seperti berikut :
Dim I as Integer
I = 1
While I <= 10
Text1.Text = Text1.Text & I & ", "
I = I + 1
Wend
Yang akan menghasilkan 1, 2, 3, 4, 5, 6, 7, 8 , 9, 10, (ada koma di belakang angka sepuluh). Sementara program yang benar menurut pengajar :
Dim I as Integer
I = 1
While I <= 10
Text1.Text = Text1.Text & I
If I <>Text1.Text = Text1.Text & ", "
I = I + 1
Wend
Senin, 02 November 2009
Mendeteksi Tombol Yang Diklik pada MessageBox (VB 2005/2008)
Dim TombolYgDiklik As System.Windows.Forms.DialogResult
TombolYgDiklik = MessageBox.Show("Keluar?", _
"Konfirmasi", MessageBoxButtons.YesNoCancel)
Select Case TombolYgDiklik
Case Windows.Forms.DialogResult.Yes
'proses jika user klik tombol YES
Case Windows.Forms.DialogResult.No
'proses jika user klik tombol NO
Case Windows.Forms.DialogResult.Cancel
'proses jika user klik tombol CANCEL
End Select
Hal serupa dapat dilakukan pada VB6 dan VB 2003.
Rabu, 12 Agustus 2009
Menampilkan Form di Tengah Layar dan di Tengah MDI Form pada VB6
Me.Left=(Screen.Width-Me.Width)/2
Me.Top=(Screen.Height-Me.Height)/2
Menampilkan Form di Tengah Layar MDI Form
Me.Left= ( frmParent.ScaleWidth – Me.Width )/2
Me.Top= ( frmParent.ScaleHeight – Me.Height ) /2
Kamis, 11 Juni 2009
Perbedaan VB 6 dan VB .Net
- VB6 baru sebagian mendukung OOP. VB .Net telah mendukung penuh OOP.
- Hasil kompilasi source code pada VB6 adalah file .exe biner (native code). VB .Net berupa file .exe intermediate language (MSIL byte code).
- Hasil kompilasi pada VB6 dapat langsung dieksekusi. VB .Net membutuhkan run time environment / framework (.Net framework)
- VB6 bermasalah pada deployment-nya (DLL hell). VB .Net tidak
- Program dari VB6 tidak dapat langsung berinteraksi dengan program dari bahasa lain. VB .Net dapat selama bahasa lain mendukung .Net
- Perintah-perintah dasar pada VB6 dan VB .Net sebagian besar masih sama kecuali untuk perintah-perintah OOP-nya
- Dari sisi IDE-nya, pengetikan kode pada VB.Net lebih cepat dari pada di VB6
- Untuk akses ke database VB.Net menggunakan ADO.Net, VB6 menggunakan ADO. ADO.Net bukan pengembangan dari ADO. Jadi ADO.Net menggunakan teknologi yang berbeda dengan ADO
- Selain itu pada VB.Net 2008, dapat menggunakan LINQ (Language Integrated Query) untuk mempermudah mengaksesan data
Kamis, 14 Mei 2009
Fungsi-Fungsi Umum VB yang Dapat Ditemukan pada Produk Microsoft (Updated)
Kesamaan pada ketiga produk tersebut, selain karena dibuat oleh perusahaan yang sama, juga karena ketiga-tiganya menggunakan "bahasa" VBA/VBS untuk pemrograman. VBA singkatan dari Visual Basic for Application, sedangkan VBS adalah singkatan dari Visual Basic Script. Bahkan ada produk yang dibuat perusahaan lain yang mendukung VBA/VBS di dalam program aplikasinya seperti Corel atau Adobe.
Berikut akan ditampilkan fungsi-fungsi umum VBA/VBS yang biasa digunakan :
Fungsi-fungsi Manipulasi String
- Len(teks) : menghitung panjang teks
- Str(angka) : mengubah angka menjadi teks
- Val(teks) : mengubah teks menjadi angka
- UCase(teks) : mengubah teks menjadi huruf besar semua
- LCase(teks) : mengubah teks menjadi huruf kecil semua
- LTrim(teks) : menghilangkan spasi di sebalah kiri teks jika ada
- RTrim(teks) : menghilangkan spasi di sebelah kanan teks jika ada
- Trim(teks) : menghilangkan spasi di sebelah kiri dan kanan teks jika ada
- Left(teks, jumlah) : mengambil teks dari kiri dengan jumlah tertentu
- Right(teks, jumlah) : mengambil teks dari kanan dengna jumlah tertentu
- Mid(teks, posisi, jumlah) : mengambil teks dari posisi tertentu dengan jumlah tertentu
- Now() : mendapatkan tanggal dan jam sistem
- IsDate() : mengecek suatu data berjenis waktu atau bukan
- Date() : mendapatkan tanggal sistem
- Time() : mendapatkan jam sistem
- Day() : mendapatkan hari berdasarkan tanggal sistem
- Month() : mendapatkan bulan berdasarkan tanggal sistem
- Year() : mendapatkan tahun berdasarkan tanggal sistem
- DateDiff() : menghitung selisih waktu berdasar periode tertentu
- DateAdd() : menghitung penambahan waktu berdasar periode tertentu
- Abs() : mengubah menjadi nilai mutlak / absolut
- Round() : pembulatan
Senin, 27 April 2009
Menggunakan Fungsi Format() pada VB 6.0
The Format function converts a value to a text string and gives you control over the string's appearance. For example, you can specify the number of decimal places for a numeric value, leading or trailing zeros, currency formats, and portions of the date. The syntax is:
Syntax
Format(expression [,format [,firstdayofweek [,firstweekofyear]]])
The firstdayofweek argument has these settings:
| Constant | Value | Description |
|---|---|---|
| vbUseSystem | 0 | Use NLS API setting. |
| vbSunday | 1 | Sunday (default) |
| vbMonday | 2 | Monday |
| vbTuesday | 3 | Tuesday |
| vbWednesday | 4 | Wednesday |
| vbThursday | 5 | Thursday |
| vbFriday | 6 | Friday |
| vbSaturday | 7 | Saturday |
The firstweekofyear argument has these settings:
| Constant | Value | Description |
|---|---|---|
| vbUseSystem | 0 | Use NLS API setting. |
| vbFirstJan1 | 1 | Start with week in which January 1 occurs (default). |
| vbFirstFourDays | 2 | Start with the first week that has at least four days in the year. |
| vbFirstFullWeek | 3 | Start with the first full week of the year. |
Notes
If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format don’t include a leading space reserved for the sign of the value; those converted using Str retain the leading space.
If you are formatting a non-localized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.
If the Calendar property setting is Gregorian and format specifies date formatting, the supplied expression must be Gregorian. If the Visual Basic Calendar property setting is Hijri, the supplied expression must be Hijri.
If the calendar is Gregorian, the meaning of format expression symbols is unchanged. If the calendar is Hijri, all date format symbols (for example, dddd, mmmm, yyyy) have the same meaning but apply to the Hijri calendar. Format symbols remain in English; symbols that result in text display (for example, AM and PM) display the string (English or Arabic) associated with that symbol. The range of certain symbols changes when the calendar is Hijri.
Formatting Symbols
| Character | Description |
|---|---|
| None No formatting | Display the number with no formatting. |
| : | Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings. |
| / | Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings. |
| C | Display the date as ddddd and display the time as t t t t t, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion. |
| D | Display the day as a number without a leading zero (1 - 31). |
| dd | Display the day as a number with a leading zero (01 - 31). |
| ddd | Display the day as an abbreviation (Sun - Sat). |
| dddd | Display the day as a full name (Sunday - Saturday). |
| ddddd | Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. The default short date format is m/d/yy. |
| dddddd | Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. The default long date format is mmmm dd, yyyy. |
| w | Display the day of the week as a number (1 for Sunday through 7 for Saturday). |
| ww | Display the week of the year as a number (1 - 53). |
| m | Display the month as a number without a leading zero (1 - 12). If m immediately follows h or hh, the minute rather than the month is displayed. |
| MM | Display the month as a number with a leading zero (01 - 12). If m immediately follows h or hh, the minute rather than the month is displayed. |
| MMM | Display the month as an abbreviation (Jan - Dec). |
| MMMM | Display the month as a full month name (January - December). |
| q | Display the quarter of the year as a number (1 - 4). |
| y | Display the day of the year as a number (1 - 366). |
| yy | Display the year as a 2-digit number (00 - 99). |
| yyyy | Display the year as a 4-digit number (100 - 9666). |
| h | Display the hour as a number without leading zeros (0 - 23). |
| hh | Display the hour as a number with leading zeros (00 - 23). |
| n | Display the minute as a number without leading zeros (0 - 59). |
| nn | Display the minute as a number with leading zeros (00 - 59). |
| s | Display the second as a number without leading zeros (0 - 59). |
| ss | Display the second as a number with leading zeros (00 - 59). |
| t t t t t | Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The default time format is h:mm:ss. |
| AM/PM | Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M. |
| am/pm | Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M. |
| A/P | Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M. |
| a/p | Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M. |
| AMPM | Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM. |
| 0 Digit placeholder | Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position. If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, display the extra digits without modification. |
| # Digit placeholder | Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression. |
| . Decimal placeholder | In some locales, a comma is used as the decimal separator. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. If you always want a leading zero displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal separator instead. The actual character used as a decimal placeholder in the formatted output depends on the Number Format recognized by your system. |
| % Percent placeholder | The expression is multiplied by 100. The percent character (%) is inserted in the position where it appears in the format string. |
| , Thousand separator | In some locales, a period is used as a thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (0 or #). Two adjacent thousand separators or a thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." You can scale large numbers using this technique. For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent thousand separators in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system. |
| : Time separator | In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings. |
| / Date separator | In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings. |
| E- E+ e- e+ Scientific format | If the format expression contains at least one digit placeholder (0 or #) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents. |
| - + $ ( ) space Display a literal character | To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" "). |
| \ Display the next character in the format string | Many characters in the format expression have a special meaning and can't be displayed as literal characters unless they are preceded by a backslash. The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\). Examples of characters that can't be displayed as literal characters are the date- and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, and /:), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !). |
| "ABC" Display the string inside the double quotation marks | To include a string in format from within code, you must use Chr(34) to enclose the text (34 is the character code for a double quotation mark). |
| @ Character placeholder | Display a character or a space. If the string has a character in the position where the @ appears in the format string, display it; otherwise, display a space in that position. Placeholders are filled from right to left unless there is an ! character in the format string. See below. |
| & Character placeholder | Display a character or nothing. If the string has a character in the position where the & appears, display it; otherwise, display nothing. Placeholders are filled from right to left unless there is an ! character in the format string. See below. |
| <> | Display all characters in lowercase format. |
| > Force uppercase | Display all characters in uppercase format. |
| ! Force left to right fill of placeholders | The default is to fill from right to left. |
Named Formats
Visual Basic provides several standard formats to use with the Format function. Instead of using symbols, you specify these formats by name in the format argument of the Format function. Always enclose the format name in double quotation marks (""). The following table lists the format names you can use.
| Named format | Description |
|---|---|
| General Number | Shows numbers as entered. |
| Currency | Shows negative numbers inside parentheses. |
| Fixed | Shows at least one digit. |
| Standard | Uses a thousands separator. |
| Percent | Multiplies the value by 100 with a percent sign at the end. |
| Scientific | Uses standard scientific notation. |
| General Date | Shows date and time if expression contains both. If expression is only a date or a time, the missing information is not displayed. |
| Long Date | Uses the Long Date format specified in the Regional Settings dialog box of the Microsoft Windows Control Panel. |
| Medium Date | Uses the dd-mmm-yy format (for example, 03-Apr-93) |
| Short Date | Uses the Short Date format specified in the Regional Settings dialog box of the Windows Control Panel. |
| Long Time | Shows the hour, minute, second, and "AM" or "PM" using the h:mm:ss format. |
| Medium Time | Shows the hour, minute, and "AM" or "PM" using the "hh:mm AM/PM" format. |
| Short Time | Shows the hour and minute using the hh:mm format. |
| Yes/No | Any nonzero numeric value (usually - 1) is Yes. Zero is No. |
| True/False | Any nonzero numeric value (usually - 1) is True. Zero is False. |
| On/Off | Any nonzero numeric value (usually - 1) is On. Zero is Off. |
Multiple Formats
A user-defined format expression can have from one to four sections separated by semicolons. (If the format argument contains one of the named formats, only one section is allowed.)
| If you use | The result is |
|---|---|
| One section | The format expression applies to all values. |
| Two sections | The first section applies to positive values and zeros, the second to negative values. |
| Three sections | The first section applies to positive values, the second to negative values, and the third to zeros. |
| Four sections | The first section applies to positive values, the second to negative values, the third to zeros, and the fourth to Null values. |
The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values.
$#,##0;($#,##0)If you include semicolons with nothing between them, the missing section is printed using the format of the positive value. For example, the following format displays positive and negative values using the format in the first section and displays "Zero" if the value is zero.
$#,##0;;\Z\e\r\oNote If you try to format a number without specifying format, Format provides the same functionality as the Str function. However, positive numbers formatted as strings using Format lack the leading space reserved for displaying the sign of the value; whereas, those converted using Str retain the leading space.
Examples
The following conversions assume that the country in the Windows Control Panel is set to "English (United States)."
| Format syntax | Result |
|---|---|
| Format(8315.4, "00000.00") | 08315.40 |
| Format(8315.4, "#####.##") | 8315.4 |
| Format(8315.4, "##,##0.00") | 8,315.40 |
| Format(315.4, "$##0.00") | $315.40 |
| Format(7, "0.00%") | 700.00% |
| Format("This Is A Test", "<") | this is a test |
| Format("This Is A Test", ">") | THIS IS A TEST |
| Format(Now, "m/d/yy") | 1/27/93 |
| Format(Now, "dddd, mmmm dd, yyyy") | Wednesday, January 27, 1993 |
| Format(Now, "d-mmm") | 27-Jan |
| Format(Now, "mmmm-yy") | January-93 |
| Format(Now, "hh:mm AM/PM") | 07:18 AM |
| Format(Now, "h:mm:ss a/p") | 7:18:00 a |
| Format(Now, "d-mmmm h:mm" | 27-January 7:18 |
| Format(Now, "d-mmmm-yy") | 27-January-93 |
| Format(Now, "d mmmm") | 27 January |
| Format(Now, "mmmm yy") | January 93 |
| Format(Now, "hh:mm AM/PM") | 08:50 PM |
| Format(Now, "h:mm:ss a/p") | 8:50:35 p |
| Format(Now, "h:mm") | 20:50 |
| Format(Now, "h:mm:ss") | 20:50:35 |
| Format(Now, "m/d/yy h:mm") | 1/27/93 20:50 |
| Format (format) | Positive 5 | Negative 5 | Decimal .5 | Null |
|---|---|---|---|---|
| Zero-length string | 5 | -5 | 0.5 | |
| 0 | 5 | -5 | 1 | |
| 0.00 | 5.00 | -5.00 | 0.50 | |
| #,##0 | 5 | -5 | 1 | |
| #,##0.00;;;Nil | 5.00 | -5.00 | 0.50 | Nil |
| $#,##0;($#,##0) | $5 | ($5) | $1 | |
| $#,##0.00;($#,##0.00) | $5.00 | ($5.00) | $0.50 | |
| 0% | 500% | -500% | 50% | |
| 0.00% | 500.00% | -500.00% | 50.00% | |
| 0.00E+00 | 5.00E+00 | -5.00E+00 | 5.00E-01 | |
| 0.00E-00 | 5.00E00 | -5.00E00 | 5.00E-01 |
Selasa, 17 Maret 2009
Pengenalan Visual Basic
Visual Basic dikembangkan oleh Microsoft dan merupakan bahasa pemrograman yang mudah dipelajari dan berkemampuan tinggi.
Kata "Basic" sebenarnya adalah singkatan dari Beginners' All-purpose Symbolic Instruction Code dikembangkan di Dartmouth College tahun 1964 di bawah pimpinan J. Kemeny dan T. Kurtz. dan digunakan di komputer mainframe. Kemudian di tahun 70-an dibuat Basic untuk dijalankan di komputer personal (PC) dengan menggunakan interpreter dan sistem operasi DOS. Basic yang populer adalah BASICA buatan IBM dan GW-BASIC buatan Microsoft yang memiliki compiler. Kemudian Microsoft mengembangkan QuickBasic yang kemudian menjadi cikal bakal Visual Basic.
Versi Visual Basic (sampai artikel ini ditulis) adalah VB 2008 (ver. 9) yang menggunakan .Net Framework 2.0. VB menggunakan .Net Framework dimulai dari versi 7 (VB.Net 2002). Sedangkan versi yang lebih baru dan belum dirilis adalah VBx (ver. 10).