Transfer Data Melalui Wifi Pada HP Android

Wahyu Raja 1 7:22 AM

Transfer Data Melalui Wifi pada HP Android

Pada beberapa tipe handphone Android Samsung terbaru telah memiliki fitur Kies Air. Fitur ini memungkinkan pengguna untuk menghubungkan hp Android ke komputer via wifi tanpa menggunakan kabel data bahkan tanpa harus menginstall aplikasi Kies atau aplikasi PC Suite terlebih dahulu di komputer. Fungsinya bukan untuk berbagi koneksi internet handphone maupun komputer, namun berfungsi untuk melakukan transfer file dari hp ke PC atau sebaliknya, untuk sinkronisasi kontak, melihat SMS, dll.
Catatan: bisa juga digunakan untuk menghubungkan handphone Android dengan handphone atau perangkat lain yang memiliki jaringan wifi
Untuk menghubungkan hp Android ke komputer via Wi-Fi ternyata tidak terlalu sulit. Apabila Anda penasaran, berikut ini tahap-tahapnya.
Update: Apabila handphone Anda bukan merk Samsung, tidak perlu khawatir, karena saat ini sudah ada beberapa aplikasi pihak ketiga yang memilliki fungsi sama seperti Kies Air.
 
Tahap #1: Install Aplikasi Kies Air di HP Android
Apabila Anda belum memiliki aplikasi ini, silahkan download dan install aplikasinya melalui Android Market. (Anda bisa juga menggunakan aplikasi AirDroid, baca update dibawah)

Tahap #2: Aktifkan aplikasi Kies Air Lalu Pilih Portable Hotspot

  1. Setelah aplikasi Kies Air terinstall > klik Start
  2. Anda akan diberi pilihan Wi-Fi dan Portable Hotspot
  3. Klik Portable Hotspot
  4. Aktifkan (beri tanda centang) fitur Portable Hotspot (wifi tether) pada ponsel Android Anda
  5. Tekan tombol BACK untuk kembali ke aplikasi Kies Air
  6. Klik tombol Start kembali, akan muncul tampilan seperti dibawah:
cara koneksi handphone android ke pc via wifi
Gambar 1. Aplikasi Kies Air

Tahap #3: Koneksikan Komputer ke Jaringan Wi-Fi HP Android

Pada layar komputer, lihat pada taskbar atau sisi kanan bawah layar. Perhatikan gambar berikut:
cara menghubungkan handphone Android ke PC via wifi
Gambar 2. Koneksikan komputer dengan jaringan wifi HP Android
  1. Klik pada gambar indikator sinyal (A)
  2. Klik pada jaringan wifi handphone Android (B). Dalam contoh ini, nama jaringan wifi pada handphone Android sudah diganti namanya menjadi “Ted’s Note N7000”. Kalau dalam kondisi standar, nama jaringannya biasanya bernama Mobile AP / Android Mobile AP, tapi bisa juga yang lain.
  3. Klik Connect (C)

Tahap #4: Buka aplikasi browser internet PC

Sekarang semua sudah siap dan Anda dapat menghubungkan HP Android ke komputer melalui jaringan wifi, berikut caranya:
  1. Buka aplikasi Browser internet di komputer. Aplikasi browser yang di Support adalah Internet Explorer versi 7/8/9, Google Chrome versi  11/12, Firefox versi 3.5/3.6/4.0 dan Safari versi 4/5
  2. Pada kolom halaman website atau web-url, ketikkan alamat atau Angka yang tertera pada aplikasi Kies Air (lihat Gambar 1.) Dalam contoh ini, ketikkan: http://192.168.43.1:8080 pada browser internet komputer> tekan Enter
  3. Setelah menekan tombol Enter di komputer, langsung lihat layar handphone Android Anda, bila muncul pilihan “Access Request” > klik Allow
  4. Selesai, kini handphone Android Anda sudah terkoneksi dengan komputer menggunakan jaringan wifi. Anda dapat melakukan unduh (download) dan unggah (upload) file, melihat file musik, foto dan video, melihat SMS, dll.
Catatan:
  1. Proses ini tidak membutuhkan koneksi internet atau layanan data. Anda dapat menghubungkan handphone ke PC walau koneksi data OFF.
  2. Untuk menghubungkan handphone Android ke handphone atau perangkat lain melalui jaringan wifi, caranya hampir sama seperti diatas, yaitu koneksikan kedua perangkat menggunakan fitur portable hotspot lalu ketikkan alamat URL yang tertera pada layar HP Android.
  3. Pada tahap #2, apabila Anda tidak ingin terkoneksi menggunakan fitur portable hotspot, Anda bisa menggunakan jaringan wifi saja. Syaratnya antara handphone Android dengan komputer harus sama-sama terhubung melalui jaringan wifi yang sama. Misalnya HP Android terhubung dengan jaringan wifi yg ada di rumah, maka komputer juga harus terhubung ke jaringan wifi rumah. Setelah itu langsung lakukan tahap #4.
Update:

Cara Transfer File Dari Android ke PC dan Sebaliknya Via WiFi Menggunakan aplikasi AirDroid

Setelah saya melakukan pencarian di Android Market (Google Play), saya menemukan aplikasi alternatif yang penggunaannya relatif lebih mudah. Aplikasi tersebut bernama “AirDroid”.
Cara penggunaan AirDroid hampir sama dengan Kies Air, lebih detailnya sebagai berikut:
  • Tahap 1: Install Aplikasi AirDroid melalui Google Play
  • Tahap 2: Nyalakan fitur Wi-Fi Tether handphone Android Anda. Caranya masuk ke Settings (Pengaturan) > Wireless anda Network (Nirkabel & Jaringan) > klik Tethering and Portable Hotspot > (pengikatan & hotspot portable) > Centang tulisan Portable Wi-Fi Hot Spot (hot spot wi fi portable) atau bisa juga tulisannya Mobile AP.
  • Tahap 3: Hubungkan komputer dengan Tablet / handphone Android (lihat Gambar 2. Diatas)
  • Tahap 4: Buka aplikasi AirDroid > Klik Settings (Menu Settings akan muncul setelah Anda menggeser bagian bawah aplikasi ini) > untuk keamanan, klik “Predefined Password” (atur agar On) > klik Edit > Masukkan Password yang diinginkan > klik OK > tekan tombol Back
  • Tahap 5: Di halaman awal aplikasi AirDroid > tekan tombol MENU > klik “Tethering & Hotspot Mode” > Tampilannya akan berubah seperti gambar dibawah:
    cara transfer musik dari komputer ke android via wifi
    Gambar 3. Aplikasi AirDroid
  • Tahap 6: Buka aplikasi Browser di Komputer lalu masukkan alamat website / ip address yang tertampil di layar aplikasi AirDroid. Dalam contoh diatas, tulis:  http://192.168.43.1:8888 > Anda kini dapat melihat isi file di hp Android, transfer data, dll tanpa menggunakan kabel data.
Selain aplikasi AirDroid dan Kies Air, ada alternatif aplikasi lain yang sejenis, namanya “Remote Web Desktop” oleh Smartdog Studio right. Semua aplikasi memiliki kelebihan dan kekurangannya masing-masing, silahkan Anda pilih yang menurut Anda paling nyaman digunakan.
 
Source : http://harga-hp.com/cara-menghubungkan-hp-android-ke-komputer-via-wi-fi

Runtime Error 339

Wahyu Raja Reply 7:17 AM

Cara Mengatasi Run-time error 339 COMDLG32.OCX File Missing

Cara Mengatasi Run-time error 339 COMDLG32.OCX File Missing
Cara Mengatasi Run-time error 339 COMDLG32.OCX File Missing. Kemarin tepatnya sewaktu habis install windows. Aku harus install banyak sekali software yang berguna untuk sehari-hari bahkan untuk online. Semuanya nggak ada masalah. Masalah baru begitu timbul ketika aku menjalankan aplikasi gratisan untuk ngecek IP aktif atau tidak yaitu X-Noul Proxy Checker. Ketika aku menjalankan program tersebut Aku mendapatkan keterangan Run-time error 339 COMDLG32.OCX File Missing. Alhasil begitu program sudah aku dobel klik ternyata hanya muncul sebentar dan error.

Usut punya usut setelah Googling. Akhirnya aku menemukan cara mengatasi Run-time error 339 COMDLG32.OCX File Missing yaitu mau nggak mau harus download file COMDLG32.OCX yang nantinya akan ditaruh di bagian system.
Bagi anda yang juga mengalami permasalahan yang sama silahkan ikuti petunjuk di bawah ini:
  1. Download dulu file COMDLg32.OCX. Silahkan klik di sini.
  2. Taruh/extrak hasil download kamu tersebut/file COMDLg32.OCX di dalam C:\Windows\system32.
  3. Jalankan Aplikasi X-Noul Proxy Checker.
Cara di atas sudah aku coba di Windows 7 Ultimate 32bit dan berhasil. Silahkan dicoba dan mohon perhatikan peletakannya. Terima kasih dan semoga artikel Cara Mengatasi Run-time error 339 COMDLG32.OCX File Missing

Recommended: Fix msflxgrd.ocx Errors

Echo Php Style

Wahyu Raja Reply 3:09 PM

Echo Multiple Lines At Once. 

echo <<<END

all sorts of text and statements...
END;

but if the following produces a parse error at line 14 which is the closing

php tag.

<?php

echo <<<TT
<tr>
<td>
<p>1. some text...</p>
</td>
<td>
<p>
<input type="radio" name="gs.$i" value="1">
</p>
</td>
</tr>
TT;
?>

 

Echo Data On Seperate Lines
I have been trying to display the result from the textarea on seperate lines for e.g

if i enter
a
b
c
in the text area it should display the same rather than what it is doing write now "a b c" Can someone please help me with this?

<?php
$action = $_REQUEST['action'];
if ($action == submit) {
print str_replace("
", "", $_POST['testt']);
}
echo "<form method=post action=?action=submit>";
echo "<textarea name=testt></textarea>";
echo "<input type=submit name=test value=test></form>"
?>

 Sql - Echo From Database With Break Lines?
This is a simple question I believe, but can't figure it out yet.I have a text area that after submit goes to a database, and then I echo this text on a page, but here is the problem, say the person writes on the textarea: Hi Robert,This is just a test!. Jason.And the message goes to the database just like that, but when I echo that, I get: Hi Robert, This is just a test!. Jason.This is the form:

<textarea name="newMessage" wrap="hard" cols="30" rows="3"></textarea>
<input type="submit" name="submit" value="Ingresar"> </>

This is the code I use to display the text:

<?php
while($row = mysql_fetch_assoc($messages)){
echo $row['mensaje']."<br/>";

[code]...

 

 

Taskmanager Script Vbs auto disabled/enabled

Wahyu Raja Reply 7:02 AM
'Enable/Disable Registry Editing tools
'© Doug Knox - rev 12/06/99

Option Explicit

'Declare variables
Dim WSHShell, n, MyBox, p, t, mustboot, errnum, vers
Dim enab, disab, jobfunc, itemtype

Set WSHShell = WScript.CreateObject("WScript.Shell")
p = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\"
p = p & "DisableRegistryTools"
itemtype = "REG_DWORD"
mustboot = "Log off and back on, or restart your pc to" & vbCR & "effect the changes"
enab = "ENABLED"
disab = "DISABLED"
jobfunc = "Registry Editing Tools are now "

'This section tries to read the registry key value. If not present an
'error is generated.  Normal error return should be 0 if value is
'present
t = "Confirmation"
Err.Clear
On Error Resume Next
n = WSHShell.RegRead (p)
On Error Goto 0
errnum = Err.Number

if errnum <> 0 then
'Create the registry key value for DisableRegistryTools with value 0
    WSHShell.RegWrite p, 0, itemtype
End If

'If the key is present, or was created, it is toggled
'Confirmations can be disabled by commenting out
'the two MyBox lines below

If n = 0 Then
    n = 1
WSHShell.RegWrite p, n, itemtype
Mybox = MsgBox(jobfunc & disab & vbCR & mustboot, 4096, t)
ElseIf n = 1 then
    n = 0
WSHShell.RegWrite p, n, itemtype
Mybox = MsgBox(jobfunc & enab & vbCR & mustboot, 4096, t)
End If

Konversi Video ke HTML5

Wahyu Raja Reply 6:53 AM
1. Downloadlah terlebih dahulu  software EasyHTML5 Video dan installah pada komputer anda.
2. Jalankan file EasyHtml5Video.exe maka akan tampilkan Kotak dialog EasyHtml5Video berikut :

3. Klik Select New video untuk memilih videonya akan dikonversikan ke HTML5. Maka akan muncul kotak dialog Open Video.

4. Pada Kotak dialog EasyHTML5video, beri pilihan pada Options dengan :
  • HTML5 (WebM) : Untuk browser Firefox 4+, Google Chrome 6+, Opera 10.60+
  • HTML5 (MP4) : Untuk Microsoft Internet Explorer 9+, Apple Safari 3.1+
  • HTML5 (OGG) : Untuk Firefox 3.5+, Google Chrome 3+ dan Opera 10.50+
  • Flash (MP4) : Untuk All flash – enabled browser.


Misalnya kita pilih HTML5 (WebM).
5. Pada pilihan Size, pilihlah ukuran video hasil konversi. Atau pilih Custom untuk menentukan Panjang dan Lebar video sesuai selera.
6. Pada pilihan Resize Method Pilihlah Letterbox atau Crop.
7. Beri pilihan pada Autoplay, jika video akan dijalankan ketika halaman dimuat. Control, untuk menampilkan control bar video. Loop untuk mengulang video secara otomatis.
8. Pada Title, isilah dengan Judul Video.
9. Klik Start untuk memulai mengkonversi. Tunggulah sampai proses selesai.
10. Jika proses konversi selesai, maka akan muncul kotak dialog Publish:

Pada pilihan Publishing method, pilih Publish to folder, untuk mempublish ke komputer anda. Atau Publish to FTP, untuk mempublish file hasil ke hosting anda.
Hasil publish-an berupa 1 file HTML berformat .webm. Kliklah file tersebut untuk menjalankannya. Maka video anda akan ditampilkan pada browser anda.
Selamat mencoba.

Source : http://amiroh.web.id/mengubah-video-ke-html5-2/

Does JavaScript need classes?

Wahyu Raja Reply 5:41 AM
Like it or not, ECMAScript 6 is going to have classes[1]. The concept of classes in JavaScript has always been polarizing. There are some who love the classless nature of JavaScript specifically because it is different than other languages. On the other hand, there are those who hate the classless nature of JavaScript because it’s different than other languages. One of the biggest mental hurdles people need to jump when moving from C++ or Java to JavaScript is the lack of classes, and I’ve had people explain to me that this was one of the reasons they either didn’t like JavaScript or decided not to continue learning.
JavaScript hasn’t had a formal definition of classes since it was first created and that has caused confusion right from the start. There are no shortage of JavaScript books and articles talking about classes as if they were real things in JavaScript. What they refer to as classes are really just custom constructors used to define custom reference types. Reference types are the closest thing to classes in JavaScript. The general format is pretty familiar to most developers, but here’s an example:
function MyCustomType(value) {
    this.property = value;
}

MyCustomType.prototype.method = function() {
    return this.property;
};
In many places, this code is described as declaring a class named MyCustomType. In fact, all it does is declare a function named MyCustomType that is intended to be used with new to create an instance of the reference type MyCustomType. But there is nothing special about this function, nothing that says it’s any different from any other function that is not being used to create a new object. It’s the usage of the function that makes it a constructor.
The code doesn’t even look like it’s defining a class. In fact, there is very little obvious relationship between the constructor definition and the one method on the prototype. These look like two completely separate pieces of code to new JavaScript developers. Yes, there’s an obvious relationship between the two pieces of code, but it doesn’t look anything like defining a class in another language.
Even more confusing is when people start to talk about inheritance. Immediately they start throwing around terms such as subclassing and superclasses, concepts that only make sense when you actually have classes to work with. Of course, the syntax for inheritance is equally confusing and verbose:
function Animal(name) {
    this.name = name;
}

Animal.prototype.sayName = function() {
    console.log(this.name);
};

function Dog(name) {
    Animal.call(this, name);
}

Dog.prototype = new Animal(null);
Dog.prototype.bark = function() {
    console.log("Woof!");
};
The two-step inheritance process of using a constructor and overriding a prototype is incredibly confusing.
In the first edition of Professional JavaScript for Web Developers, I used the term “class” exclusively. The feedback I received indicated that people found this confusing and so I changed all references to “class” in the second edition to “type”. I’ve used that terminology ever since and it helps to eliminate a lot of the confusion.
However, there is still a glaring problem. The syntax for defining custom types is confusing and verbose. Inheritance between two types is a multistep process. There is no easy way to call a method on a supertype. Bottom line: it’s a pain to create and manage custom types. If you don’t believe that this is a problem, just look at the number of JavaScript libraries that have introduced their own way of defining custom types, inheritance, or both:
  • YUI – has Y.extend() to perform inheritance. Also adds a superclass property when using this method.[2]
  • Prototype – has Class.create() and Object.extend() for working with objects and “classes”.[3]
  • Dojo – has dojo.declare() and dojo.extend().[4]
  • MooTools – has a custom type called Class for defining and extending classes.[5]
It’s pretty obvious that there’s a problem when so many JavaScript libraries are defining solutions. Defining custom types is messy and not at all intuitive. JavaScript developers need something better than the current syntax.
ECMAScript 6 classes are actually nothing more than syntactic sugar on top of the patterns you are already familiar with. Consider this example:
class MyCustomType {
    constructor(value) {
        this.property = value;
    }

    method() {
        return this.property;
    }
}
This ECMAScript 6 class definition actually desugars to the previous example in this post. An object created using this class definition works exactly the same as an object created using the constructor definition from earlier. The only difference is a more compact syntax. How about inheritance:
class Animal {
    constructor(name) {
        this.name = name;
    }

    sayName() {
        console.log(this.name);
    }
}

class Dog extends Animal {
    constructor(name) {
        super(name);
    }

    bark() {
        console.log("Woof!");
    }
}
This example desugars to the previous inheritance example. The class definitions are compact and the clunky multistep inheritance pattern has been replaced with a simple extends keyword. You also get the benefit of super() inside of class definitions so you don’t need to reference the supertype in more than one spot.
All of the current ECMAScript 6 class proposal is simply new syntax on top of the patterns you already know in JavaScript. Inheritance works the same as always (prototype chaining plus calling a supertype constructor), methods are added to prototypes, and properties are declared in the constructor. The only real difference is less typing for you (no pun intended). Class definitions are just type definitions with a different syntax.
So while some are having a fit because ECMAScript 6 is introducing classes, keep in mind that this concept of classes is abstract. It doesn’t fundamentally change how JavaScript works; it’s not introducing a new thing. Classes are simply syntactic sugar on top of the custom types you’ve been working with for a while. This solves a problem that JavaScript has had for a long time, which is the verbosity and confusion of defining your own types. I personally would have liked to use the keyword type instead of class, but at the end of the day, this is just a matter of semantics.
So does JavaScript need classes? No, but JavaScript definitely needs a cleaner way of defining custom types. It just so happens the way to do that has a name of “class” in ECMAScript 6. And if that helps developers from other languages make an easier transition into JavaScript, then that’s a good thing.

Source : http://www.nczonline.net/blog/2012/10/16/does-javascript-need-classes/

Contoh Program Sederhana Zend Framework

Wahyu Raja Reply 8:02 AM
Pertama kita buat direktori dimana kita akan membuat web.Caranya dengan membuka xampp_shell kemudian ketik zf create project web(web adalah nama folder dimana kita akan membuat poyek nanti)Setelah itu maka didalam Xampp akan muncul sebuah folder web seperti gambar ini
Bootstrap file
File bootstrap sederhananya adalah file "index.php" yang terletak pada webroot Web Server (htdocs). File inilah yang melakukan konfigurasi awal Zend Framework.Buatlah file index.php dan letakkan pada direktory htdocs:


/* Setting parameter PHP untuk melaporkan semua error. Tidak digunakan dalam production */
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
/* set direktori aplikasi dan library */
$lib_paths = array();
$lib_paths[] = "d:/xampp/htdocs/web/library";
$lib_paths[] = "d:xampp/htdocs/web/application";
$inc_path = implode(PATH_SEPARATOR, $lib_paths);
set_include_path($inc_path);

/* Load class-dasar dasar yang dibutuhkan */
require_once 'Zend/Loader.php';
require_once 'Zend/Controller/Front.php';
/* kode ini diletakkan dalam blok try agar mempermudah kita debugging */
try {
Zend_Loader::loadClass('Zend_Controller_Front');
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setParam('noErrorHandler', true);
$frontController->setControllerDirectory('d:/xampp/htdocs/web/application/controllers');
$frontController->dispatch();
}
/* catch jika terjadi exception dan laporkan */
catch (Exception $exp) {
$contentType = 'text/html';
header("Content-Type: $contentType; charset=utf-8");
echo 'exception!!';
echo ' ' . $exp->getMessage() . '

';  
echo $exp->getTraceAsString();
}

?>
2. Controller
Konvensi Zend Framework mewajibkan setiap class controller untuk diberi nama *Controller dan berada didalam file *Controller.php . Sehingga jika Anda membuat controller dengan nama "index", maka nama class haruslah "indexController" dan berada dalam file "indexController.php"Di dalam kelas controller, Anda dapat menambahkan Action. Yaitu kode yang akan diproses jika mendapat request dari browser.Misalnya jika ada request ke: " http://localhost/index/halo " maka jika dilihat dari sudut pandang Zend Framework adalah: Eksekusi Action "haloAction" yang berada dalam class (controller) "indexController".Kembali ke aplikasi kita, buatlah file indexController.php dan simpan di direktori: d:\web\Application\controllers sebelumnya saya ingatkan lagi, penamaan file dan peletakan file adalah konvensi yang harus diikuti.

Zend_Loader::loadClass('Zend_Controller_Action');
class indexController extends Zend_Controller_Action {
public function indexAction() {}
}
?>
Kita telah membuat sebuah controller dengan nama "indexController" yang memiliki sebuah action yang bernama "indexAction". Pada dasarnya controller adalh sebuah class yang diturunkan dari class "Zend_Controller_Action". Sedangkan action pada dasarnya adalah sebuah function.

Seperti yang terlihat pada contoh kode diatas, action yang kita buat adalah sebuah fungsi kosong. Kita tidak melakukan apa-apa pada action ini melainkan hanya menampilkan tulisan "Hello World" dan akan kita defenisikan pada view.
3. View
View mendefenisikan presentation. Atau tampilan dan pada konteks Web adalah kode HTML. Sekarang kita akan membuat view untuk indexAction yang telah didefenisikan sebelumnya


Buatlah file dengan nama: "index.phtml" dan simpan dalam direktori: d:\web\Application\views\scripts\index\ :
<center><h1>HELLO WORLD!!h1>center>
4 .htacces
Kita akan membuat file .htaccess yang akan melakukan routing semua request kecuali resource (gambar, javascript, stylesheet, dll) diarahkan ke index.php . Lalu front controller akan mengambil alih dari sini.

File .htaccess:
RewriteEngine on
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php

Simpan file tersebut dalam direktori wwwroot (htdocs).

Sekarang semuanya sudah selesai, silahkan akses applikasi Anda di: http://localhost/web/public

untuk lebih jelasnya bisa lihat video dibawah ini:
http://www.blogger.com/video-play.mp4?contentId=9460e6845a58067&type=video%2Fmp4 

New HTML5 Input Types and Attributes

Wahyu Raja Reply 6:43 AM

New HTML5 Input Types and Attributes

HTML5 defines a variety of new input types: sliders, number spinners, popup calendars, color choosers, autocompleting suggest boxes, and more. The beauty of these elements is that you can use them now: for browsers that don't support a particular input type, there is automatic fallback to standard textfields. There are two keys to understanding why the automatic fallback works consistently in all major browsers:
  • The default type for input elements is "text".
  • All browsers ignore unknown attributes.
The consequence of these two points is that if you say <input type="foo" bar="baz"/>, all browsers will treat this identically to <input type="text"/> (unless "foo" is a recognized input type or "bar" is a recognized attribute of the input element). For each of the new input types, we present a high-level description, an overview of the syntax, a description of the main attributes, a summary of which current browsers support it, and an example you can experiment with in your browser. Please send corrections and suggested improvements to hall@coreservlets.com.

Example Regular Expressions

Wahyu Raja Reply 9:06 PM
Regular expressions are a language of their own. When you learn a new programming language, they’re this little sub-language that makes no sense at first glance. Many times you have to read another tutorial, article, or book just to understand the “simple” pattern described. Today, we’ll review eight regular expressions that you should know for your next coding project.

Background Info on Regular Expressions

This is what Wikipedia has to say about them:
In computing, regular expressions provide a concise and flexible means for identifying strings of text of interest, such as particular characters, words, or patterns of characters. Regular expressions (abbreviated as regex or regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.
Now, that doesn’t really tell me much about the actual patterns. The regexes I’ll be going over today contains characters such as \w, \s, \1, and many others that represent something totally different from what they look like.
If you’d like to learn a little about regular expressions before you continue reading this article, I’d suggest watching the Regular Expressions for Dummies screencast series.
The eight regular expressions we’ll be going over today will allow you to match a(n): username, password, email, hex value (like #fff or #000), slug, URL, IP address, and an HTML tag. As the list goes down, the regular expressions get more and more confusing. The pictures for each regex in the beginning are easy to follow, but the last four are more easily understood by reading the explanation.
The key thing to remember about regular expressions is that they are almost read forwards and backwards at the same time. This sentence will make more sense when we talk about matching HTML tags.
Note: The delimiters used in the regular expressions are forward slashes, “/”. Each pattern begins and ends with a delimiter. If a forward slash appears in a regex, we must escape it with a backslash: “\/”.

1. Matching a Username

Matching a username

Pattern:

  1. /^[a-z0-9_-]{3,16}$/  

Description:

We begin by telling the parser to find the beginning of the string (^), followed by any lowercase letter (a-z), number (0-9), an underscore, or a hyphen. Next, {3,16} makes sure that are at least 3 of those characters, but no more than 16. Finally, we want the end of the string ($).

String that matches:

my-us3r_n4m3

String that doesn’t match:

th1s1s-wayt00_l0ngt0beausername (too long)

2. Matching a Password

Matching a password

Pattern:

  1. /^[a-z0-9_-]{6,18}$/  

Description:

Matching a password is very similar to matching a username. The only difference is that instead of 3 to 16 letters, numbers, underscores, or hyphens, we want 6 to 18 of them ({6,18}).

String that matches:

myp4ssw0rd

String that doesn’t match:

mypa$$w0rd (contains a dollar sign)

3. Matching a Hex Value

Matching a hex valud

Pattern:

  1. /^#?([a-f0-9]{6}|[a-f0-9]{3})$/  

Description:

We begin by telling the parser to find the beginning of the string (^). Next, a number sign is optional because it is followed a question mark. The question mark tells the parser that the preceding character — in this case a number sign — is optional, but to be “greedy” and capture it if it’s there. Next, inside the first group (first group of parentheses), we can have two different situations. The first is any lowercase letter between a and f or a number six times. The vertical bar tells us that we can also have three lowercase letters between a and f or numbers instead. Finally, we want the end of the string ($).
The reason that I put the six character before is that parser will capture a hex value like #ffffff. If I had reversed it so that the three characters came first, the parser would only pick up #fff and not the other three f’s.

String that matches:

#a3c113

String that doesn’t match:

#4d82h4 (contains the letter h)

4. Matching a Slug

Matching a slug

Pattern:

  1. /^[a-z0-9-]+$/  

Description:

You will be using this regex if you ever have to work with mod_rewrite and pretty URL’s. We begin by telling the parser to find the beginning of the string (^), followed by one or more (the plus sign) letters, numbers, or hyphens. Finally, we want the end of the string ($).

String that matches:

my-title-here

String that doesn’t match:

my_title_here (contains underscores)

5. Matching an Email

Matching an email

Pattern:

  1. /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/  

Description:

We begin by telling the parser to find the beginning of the string (^). Inside the first group, we match one or more lowercase letters, numbers, underscores, dots, or hyphens. I have escaped the dot because a non-escaped dot means any character. Directly after that, there must be an at sign. Next is the domain name which must be: one or more lowercase letters, numbers, underscores, dots, or hyphens. Then another (escaped) dot, with the extension being two to six letters or dots. I have 2 to 6 because of the country specific TLD’s (.ny.us or .co.uk). Finally, we want the end of the string ($).

String that matches:

john@doe.com

String that doesn’t match:

john@doe.something (TLD is too long)

6. Matching a URL

Matching a url

Pattern:

  1. /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/  

Description:

This regex is almost like taking the ending part of the above regex, slapping it between “http://” and some file structure at the end. It sounds a lot simpler than it really is. To start off, we search for the beginning of the line with the caret.
The first capturing group is all option. It allows the URL to begin with “http://”, “https://”, or neither of them. I have a question mark after the s to allow URL’s that have http or https. In order to make this entire group optional, I just added a question mark to the end of it.
Next is the domain name: one or more numbers, letters, dots, or hypens followed by another dot then two to six letters or dots. The following section is the optional files and directories. Inside the group, we want to match any number of forward slashes, letters, numbers, underscores, spaces, dots, or hyphens. Then we say that this group can be matched as many times as we want. Pretty much this allows multiple directories to be matched along with a file at the end. I have used the star instead of the question mark because the star says zero or more, not zero or one. If a question mark was to be used there, only one file/directory would be able to be matched.
Then a trailing slash is matched, but it can be optional. Finally we end with the end of the line.

String that matches:

http://net.tutsplus.com/about

String that doesn’t match:

http://google.com/some/file!.html (contains an exclamation point)

7. Matching an IP Address

Matching an IP address

Pattern:

  1. /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/  

Description:

Now, I’m not going to lie, I didn’t write this regex; I got it from here. Now, that doesn’t mean that I can’t rip it apart character for character.
The first capture group really isn’t a captured group because
  1. ?:  
was placed inside which tells the parser to not capture this group (more on this in the last regex). We also want this non-captured group to be repeated three times — the {3} at the end of the group. This group contains another group, a subgroup, and a literal dot. The parser looks for a match in the subgroup then a dot to move on.
The subgroup is also another non-capture group. It’s just a bunch of character sets (things inside brackets): the string “25″ followed by a number between 0 and 5; or the string “2″ and a number between 0 and 4 and any number; or an optional zero or one followed by two numbers, with the second being optional.
After we match three of those, it’s onto the next non-capturing group. This one wants: the string “25″ followed by a number between 0 and 5; or the string “2″ with a number between 0 and 4 and another number at the end; or an optional zero or one followed by two numbers, with the second being optional.
We end this confusing regex with the end of the string.

String that matches:

73.60.124.136 (no, that is not my IP address :P)

String that doesn’t match:

256.60.124.136 (the first group must be “25″ and a number between zero and five)

8. Matching an HTML Tag

Matching an HTML tag

Pattern:

  1. /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/  

Description:

One of the more useful regexes on the list. It matches any HTML tag with the content inside. As usually, we begin with the start of the line.
First comes the tag’s name. It must be one or more letters long. This is the first capture group, it comes in handy when we have to grab the closing tag. The next thing are the tag’s attributes. This is any character but a greater than sign (>). Since this is optional, but I want to match more than one character, the star is used. The plus sign makes up the attribute and value, and the star says as many attributes as you want.
Next comes the third non-capture group. Inside, it will contain either a greater than sign, some content, and a closing tag; or some spaces, a forward slash, and a greater than sign. The first option looks for a greater than sign followed by any number of characters, and the closing tag. \1 is used which represents the content that was captured in the first capturing group. In this case it was the tag’s name. Now, if that couldn’t be matched we want to look for a self closing tag (like an img, br, or hr tag). This needs to have one or more spaces followed by “/>”.
The regex is ended with the end of the line.

String that matches:

<a href=”http://net.tutsplus.com/”>Nettuts+</a>

String that doesn’t match:

<img src=”img.jpg” alt=”My image>” /> (attributes can’t contain greater than signs)

Conclusion

I hope that you have grasped the ideas behind regular expressions a little bit better. Hopefully you’ll be using these regexes in future projects! Many times you won’t need to decipher a regex character by character, but sometimes if you do this it helps you learn. Just remember, don’t be afraid of regular expressions, they might not seem it, but they make your life a lot easier. Just try and pull out a tag’s name from a string without regular expressions! ;)

Source : http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/

Simple CALCULATOR - VB.NET

Wahyu Raja Reply 6:04 PM

Dear agan-agan para pecinta koding.. lagi-lagi berawal dari tugas kuliah baru-baru ini, dapet tugas buat perhitungan matematika dasar. mari kita belajar bersama-sama lagi. buat yang sudah master mohon petunjuknya, mungkin aplikasi ini terlalu dasar.
seperti pada tutorial sebelumnya silahkan dipersiapkan form kalkulator anda ya paling tidak sama kayak punya saya. ga perlu buat 2 form ya !! itu cuma buat membedakan saja kondisi "ON" atau "OFF" saja.
nah ini dia kodingnya :
Public Class KALKULATOR372

  Dim STR_01 As Double
  Dim STR_02 As Double
  Dim STR_03 As String

  Private Sub BACKSPACE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BACKSPACE.Click

  Dim X As New Integer

  If (TxtLAYAR.Text.Length > 0) Then

  X = TxtLAYAR.Text.Length
  TxtLAYAR.Text = TxtLAYAR.Text.Remove(X - 1, 1)

  End If

  End Sub

  Private Sub ANGKA_01_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_01.Click

  TxtLAYAR.Text += ANGKA_01.Text

  End Sub

  Private Sub ANGKA_02_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_02.Click

  TxtLAYAR.Text += ANGKA_02.Text

  End Sub

  Private Sub ANGKA_03_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_03.Click

  TxtLAYAR.Text += ANGKA_03.Text

  End Sub

  Private Sub ANGKA_04_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_04.Click

  TxtLAYAR.Text += ANGKA_04.Text

  End Sub

  Private Sub ANGKA_05_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_05.Click

  TxtLAYAR.Text += ANGKA_05.Text

  End Sub

  Private Sub ANGKA_06_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_06.Click

  TxtLAYAR.Text += ANGKA_06.Text

  End Sub

  Private Sub ANGKA_07_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_07.Click

  TxtLAYAR.Text += ANGKA_07.Text

  End Sub

  Private Sub ANGKA_08_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_08.Click

  TxtLAYAR.Text += ANGKA_08.Text

  End Sub

  Private Sub ANGKA_09_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_09.Click

  TxtLAYAR.Text += ANGKA_09.Text

  End Sub

  Private Sub ANGKA_NOL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_NOL.Click

  TxtLAYAR.Text += ANGKA_NOL.Text

  End Sub

  Private Sub ANGKA_00_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ANGKA_00.Click

  TxtLAYAR.Text += ANGKA_00.Text

  End Sub

  Private Sub SAMADENGAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAMADENGAN.Click

  STR_02 = Val(TxtLAYAR.Text)

  If STR_03 = "--" Then
  TxtLAYAR.Text = STR_01 - STR_02
  ElseIf STR_03 = "+" Then
  TxtLAYAR.Text = STR_01 + STR_02
  ElseIf STR_03 = "X" Then
  TxtLAYAR.Text = STR_01 * STR_02
  ElseIf STR_03 = "/" Then
  TxtLAYAR.Text = STR_01 / STR_02
  End If
  End Sub

  Private Sub CLEAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CLEAR.Click

  TxtLAYAR.Text = ""
  STR_03 = ""

  End Sub

  Private Sub KURANG_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KURANG.Click

  STR_01 = Val(TxtLAYAR.Text)
  TxtLAYAR.Text = ""
  STR_03 = KURANG.Text

  End Sub

  Private Sub TAMBAH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click

  STR_01 = Val(TxtLAYAR.Text)
  TxtLAYAR.Text = ""
  STR_03 = TAMBAH.Text

  End Sub

  Private Sub KALI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KALI.Click

  STR_01 = Val(TxtLAYAR.Text)
  TxtLAYAR.Text = ""
  STR_03 = KALI.Text

  End Sub

  Private Sub BAGI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BAGI.Click

  STR_01 = Val(TxtLAYAR.Text)
  TxtLAYAR.Text = ""
  STR_03 = BAGI.Text

  End Sub

  Private Sub TITIK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TITIK.Click

  TxtLAYAR.Text += TITIK.Text

  End Sub

  Private Sub BUTTON_NONAKTIF()

  CLEAR.Enabled = False
  BACKSPACE.Enabled = False

  ANGKA_01.Enabled = False
  ANGKA_02.Enabled = False
  ANGKA_03.Enabled = False
  ANGKA_04.Enabled = False
  ANGKA_05.Enabled = False
  ANGKA_06.Enabled = False
  ANGKA_07.Enabled = False
  ANGKA_08.Enabled = False
  ANGKA_09.Enabled = False
  ANGKA_NOL.Enabled = False
  ANGKA_00.Enabled = False

  KALI.Enabled = False
  BAGI.Enabled = False
  TAMBAH.Enabled = False
  KURANG.Enabled = False
  TITIK.Enabled = False
  SAMADENGAN.Enabled = False

  End Sub

  Private Sub BUTTON_AKTIF()

  CLEAR.Enabled = True
  BACKSPACE.Enabled = True

  ANGKA_01.Enabled = True
  ANGKA_02.Enabled = True
  ANGKA_03.Enabled = True
  ANGKA_04.Enabled = True
  ANGKA_05.Enabled = True
  ANGKA_06.Enabled = True
  ANGKA_07.Enabled = True
  ANGKA_08.Enabled = True
  ANGKA_09.Enabled = True
  ANGKA_NOL.Enabled = True
  ANGKA_00.Enabled = True

  KALI.Enabled = True
  BAGI.Enabled = True
  TAMBAH.Enabled = True
  KURANG.Enabled = True
  TITIK.Enabled = True
  SAMADENGAN.Enabled = True

  End Sub

  Private Sub KALKULATOR372_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated

  Call BUTTON_NONAKTIF()

  End Sub

  Private Sub ONOFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ONOFF.Click

  If ONOFF.Text = "ON" Then

  Call BUTTON_AKTIF()
  ONOFF.Text = "OFF"

  ElseIf ONOFF.Text = "OFF" Then

  Call BUTTON_NONAKTIF()
  ONOFF.Text = "ON"
  TxtLAYAR.Text = ""

  End If

  End Sub
End Class

VBKey Codes

Wahyu Raja Reply 4:50 PM
For those of you who don't know every vbKey code.... 
 

Here is a list:
 
vbKeyLButton    Left Mouse Button
vbKeyRButton    Right Mouse Button
vnKeyCancel     Cancel Key
vbKeyMButton    Middle Mouse button
vbKeyBack       Back Space Key
vbKeyTab        Tab Key
vbKeyClear      Clear Key
vbKeyReturn     Enter Key
vbKeyShift      Shift Key
vbKeyControl    Ctrl Key
vbKeyMenu       Menu Key
vbKeyPause      Pause Key
vbKeyCapital    Caps Lock Key
vbKeyEscape     Escape Key
vbKeySpace      Spacebar Key
vbKeyPageUp     Page Up Key
vbKeyPageDown   Page Down Key
vbKeyEnd        End Key
vbKeyHome       Home Key
vbKeyLeft       Left Arrow Key
vbKeyUp         Up Arrow Key
vbKeyRight      Right Arrow Key
vbKeyDown       Down Arrow Key
vbKeySelect     Select Key
vbKeyPrint      Print Screen Key
vbKeyExecute    Execute Key
vbKeySnapshot   Snapshot Key
vbKeyInsert     Insert Key
vbKeyDelete     Delete Key
vbKeyHelp       Help Key
vbKeyNumlock    Delete Key

vbKeyA through vbKeyZ are the key code constants for the alphabet
vbKey0 through vbKey9 are the key code constants for numbers
vbKeyF1 through vbKeyF16 are the key code constants for the function keys
vbKeyNumpad0 through vbKeyNumpad9 are the key code constants for the numeric key pad

Math signs are:
vbKeyMultiply      -  Multiplication Sign (*)
vbKeyAdd             - Addition Sign (+)
vbKeySubtract     - Minus Sign (-)
vbKeyDecimal    - Decimal Point (.)
vbKeyDivide        - Division sign (/)
vbKeySeparator  - Enter (keypad) sign

Checkbox Control VB

Wahyu Raja Reply 7:22 AM
Screenshot






The Code



Private Sub cmdExit_Click()
    End
End Sub
___________________________________________________
Private Sub cmdShow_Click()
    Dim total As Integer
    total = 0
    tea = ""
    sandwitch = ""
    pizza = ""
    colddrinks = ""
    greentea = ""
    coffee = ""


    If chkTea.Value = 1 Then
        tea = " Tea,"
        total = total + 5
    End If

    If chkSandwich.Value = 1 Then
        sandwich = " Sandwich,"
        total = total + 50
    End If

    If chkPizza.Value = 1 Then
        pizza = " Pizza,"
        total = total + 50
    End If

    If chkColdDrinks.Value = 1 Then
        colddrinks = " Cold Drinks,"
        total = total + 6
    End If

    If chkGreenTea.Value = 1 Then
        greentea = " Green Tea,"
        total = total + 7
    End If

    If chkCoffee.Value = 1 Then
        coffee = " Coffee,"
        total = total + 9
    End If


    MsgBox "You have ordered " & tea & _
    sandwich & pizza & colddrinks & greentea & coffee & _
    " and the total price is $" & total, vbInformation, "Thanks"


End Sub
Source : http://www.vbtutes.com/2012/08/program-28-restuarant-order-1.html

Search

Ikuti Channel Youtube Aku Yaa.. Jangan Lupa di subscribe. Terima kasih.

Google+ Followers

Popular Posts

Translate