[VB.NET] Dialog



Description
     Add dialog component to form and write this code :

savedialog1.InitialDirectory = "D:\" 'setup initial directory
savedialog1.Filter = "Text Files (*.txt)|*.txt" 'Create type extention file

If savePathPasuruan.ShowDialog = DialogResult.OK Then
   'if result ok 
Else
   'if result false
End If

[VB.NET] Styling Nominal Currency in textbox


Description
     if you make an application for finance but you not styling the text box, it will horrible for user. a mistake cannot be tolerated in finance , Because it is always associated with the company's money. who will be responsible ? definite user of the financial department. IT departments do not want to be responsible as well as the finance department because of lack of applications. to prevent this i will give a function to styling nominal currency like in finance. for example :

2500000 => horrible format , now compare with this 2,500,000 => readable

now this function :


Public Function currencyFormat(ByVal money As String) As String
    Dim formattedString As String = ""
    For i = 1 To money.Length
        If i >= 3 Then
            If i Mod 3 = 1 Then
                formattedString = money.Substring(money.Length - i, 1) & "," & formattedString
            Else
                formattedString = money.Substring(money.Length - i, 1) & formattedString
            End If
        Else
            formattedString = money.Substring(money.Length - i, 1) & formattedString
        End If
    Next i
    Return formattedString
End Function

To Use :
textbox1 => got_focus event :
textbox1 .Text = Replace(textbox1.Text, ",", "")

textbox1 => lostfocus_focus event :
textbox1.Text = currencyFormat(Replace(textbox1.Text, ",", ""))

if you want this value entered in database, don't forget always to sanitize character ',' (comma) to prevent error in query.

work's great :D

[VB.NET] dataGridView to Excel Class


Description
     In this article i will share excel class which can convert the data in the DataGrid to excel, very usefull better than code from scratch. the limitation is the data appear in datagridview same data in excel later, you cannot costumize the block field.


How To

here's the exportExcel Class :
Imports System.Windows.Forms
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Threading
Imports System.Globalization
Imports System.Net

Public Class exportExcel
    Dim oexcel As Excel.Application = New Excel.Application()
    Dim obook As Excel.Workbook
    Dim osheet As Object
    Dim customFormatDate As String = "dd/MM/yyyy"

    Public Sub exportExcel(ByVal dataGrid As DataGridView, ByVal savePath As String, ByRef messageOut As Label)
        Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
        oexcel = CreateObject("Excel.Application")
        obook = oexcel.Workbooks.Add
        osheet = obook.Worksheets(1)

        'format Header, row index always start at 1
        For columnIndex = 1 To dataGrid.Columns.Count
            osheet.Range(intToAlphabet(columnIndex) & 1).NumberFormat = "@"
            osheet.Range(intToAlphabet(columnIndex) & 1).Value = dataGrid.Columns(columnIndex - 1).HeaderText
            Application.DoEvents()
            messageOut.Text = "Write at : Col:" & intToAlphabet(columnIndex) & " " & "Row:1"
        Next columnIndex

        'format Row cell
        For rowIndex = 0 To dataGrid.Rows.Count - 1 'row start from 2 , because row 1 is header
            For columnIndex = 0 To dataGrid.Columns.Count - 1
                If dataGrid.Columns(columnIndex).ValueType.ToString = GetType(Date).ToString Then
                    'Jika column type = DATE
                    osheet.Range(intToAlphabet(columnIndex + 1) & rowIndex + 2).Value = Format(dataGrid.Rows(rowIndex).Cells(columnIndex).Value(), customFormatDate)
                Else
                    'Jika column type = STRING
                    osheet.Range(intToAlphabet(columnIndex + 1) & rowIndex + 2).NumberFormat = "@"
                    osheet.Range(intToAlphabet(columnIndex + 1) & rowIndex + 2).Value = dataGrid.Rows(rowIndex).Cells(columnIndex).Value()
                End If

                Application.DoEvents()
                messageOut.Text = "Write at : Col:" & intToAlphabet(columnIndex + 1) & " " & "Row:" & rowIndex + 2
            Next columnIndex
        Next rowIndex

        oexcel.DisplayAlerts = False

        Try
            obook.SaveAs(savePath, Excel.XlFileFormat.xlOpenXMLWorkbook)
        Catch e As Exception
            MsgBox(e.Message & vbCrLf & "Process cancelled !!", vbCritical, "Abort")
        End Try

        oexcel.Quit()
        killCurrentExcel(oexcel) ' you can find this function in different article
        oexcel = Nothing
    End Sub

    Private Sub killCurrentExcel(ByVal oexcel As Object)
        Dim proc As System.Diagnostics.Process
        Dim intPID As Integer
        Dim intResult As Integer
        Dim iHandle As IntPtr
        Dim strVer As String

        strVer = oexcel.Version
        iHandle = IntPtr.Zero
        If CInt(strVer) > 9 Then
            iHandle = New IntPtr(CType(oexcel.Parent.Hwnd, Integer))
        Else
            iHandle = FindWindow(Nothing, oexcel.Caption)
        End If
        oexcel.Workbooks.Close()
        oexcel.Quit()
        Marshal.ReleaseComObject(oexcel)
        oexcel = Nothing
        intResult = GetWindowThreadProcessId(iHandle, intPID)
        proc = System.Diagnostics.Process.GetProcessById(intPID)
        proc.Kill()
    End Sub

    Private Function intToAlphabet(ByVal iCol As Integer) As String
        Dim iAlpha As Integer
        Dim iRemainder As Integer
        intToAlphabet = Nothing 'init value 

        iAlpha = Int(iCol / 27)
        iRemainder = iCol - (iAlpha * 26)
        If iAlpha > 0 Then
            intToAlphabet = Chr(iAlpha + 64)
        End If
        If iRemainder > 0 Then
            intToAlphabet = intToAlphabet & Chr(iRemainder + 64)
        End If
    End Function
End Class


To Use this class :

1. Add reference excel Microsoft Excel 12.0 Object Library.
2. Use this code :
     Dim objExportExcel As New exportExcel
     objExportExcel.exportExcel(dataGridView, "D:\pathSave", yourlabelobject)
3. and wait until file excel has been created

[VB.NET] Add button icon / image beside text


How To :

  1.  Add 1 button on form
  2.  Prepare an image (.png, size 16 x 16), you get the image at iconarchive.com (my favourite).
  3.  Right click on button > properties , find Image and import your image (png) to resources.
  4.  After the image appear on button, set imageAlign to Middle Center.
  5.  Now set textAlign to Middle Right and set textImageRelation to ImageBeforeText.
  6.  here's the result :

 
     
however the size of the width is changed, the text and the image stays in the middle.

ENJOY :D

[VB.NET] All About the use of dataGridView


Description
     This article we will discuss all about dataGridView in VB.NET, This article may be incomplete because i am just human (Above the sky there is another sky). so i need your help if something usefull about dataGridViewthat's not include in this article. you can add by comment below. if very usefull i will include in this article. many thanks :)


OK, Let's start :

1.  i want to make color datagrid, especially column header or row header
-----  enableheadersvisualstyles => FALSE
-----  to edit color column header you can click on property : columnheadersdefaultcellstyle
-----  to edit color row header you can click on property : rowheadersdefaultcellstyle

2. i want to get cell value when row get selected
----- respon the event selected using : SelectionChanged
----- to get row index : dataGridView.CurrentCell.RowIndex
----- to get cell value : dataGridView.Rows(RowIndex).Cells(ColumnIndex).Value()

3. i want every click in dataGridView = click row , not click current cell
----- on property set SelectionMode = fullRowSelect

4. i need to givecell color like white black white black
-----  you can goto here dataGridView Color

5. i need filter record in dataGridView without requery
----- you can use bindingSource, but still need current dataSource that you use. here's the example
        Dim sourceFilter As New BindingSource()
        sourceFilter.DataSource = dataGridView.DataSource 'current data source is exist
        sourceFilter.Filter = "[FIELD for FILTER] like '%" & txtFilter.Text & "%'"
        dataGridView.Refresh()

6. i want change date format in some column
------ dataGridView.Columns(indexcolumn).DefaultCellStyle.Format = "dd/MM/yyyy"

7. i want color code from HTML
----- colortranslator.fromhtml("#fafafa")

8. i want fit header column
----- autosizecolumnmode = fill

9. i want get value of multiple selection
 For Each selectedItem As DataGridViewRow In selectedItems
                'Add code to handle whatever you want for each row
                msgbox(selectedItem.Index) 'row index
 Next


[VB.NET] CRUD Class ADO.NET


Description

This article i will show you crud using template class that i create. very simple to use and clean code. here's this class :


Public Class database
    Implements IDisposable

    Public Function runningQuery(ByVal querystring As String) As DataTable
        Dim dbcmd, adaptor, datacontent
        Dim dbconn = New OleDbConnection

        dbconn.ConnectionString = "FILE NAME=" & My.Application.Info.DirectoryPath & "\connectionFile.udl"
        dbcmd = New OleDbCommand(querystring, dbconn)
        dbcmd.CommandType = CommandType.Text
        adaptor = New OleDbDataAdapter(dbcmd)
        datacontent = New DataTable
        adaptor.Fill(datacontent)
        dbconn.Close()
        Return datacontent
    End Function

    Public Sub executeQuery(ByVal querystring As String)
        Dim dbcmd
        Dim dbconn = New OleDbConnection
        dbconn.ConnectionString = "FILE NAME=" & My.Application.Info.DirectoryPath & "\connectionFile.udl"
        dbconn.Open()

        'Execute Query :
        ' INSERT : "insert into table (field1,field2) values ('1','yeah')"
        ' Delete : "update table set field1 ='abc' where  field2 = '1' "
        ' Update : "delete from table where field1 = '1' "

        dbcmd = New OleDbCommand(querystring, dbconn)
        dbcmd.CommandType = CommandType.Text
        dbcmd.ExecuteReader()
        dbconn.Close()
    End Sub
End Class

here's how to use this class :

  1. Add Class and copy paste class code above, give name the class : database
  2. Define and make object from that class :
    Dim objdatabase As New database
  3. now you can use the object, INSERT DELETE and UPDATE use executeQuery() function because it's doesn't return any value. SELECT use runningQuery() function and it's always return type data : dataTable. 
  4. Example runningQuery()
    Dim objdatabase As New database
    Dim employeeData as dataTable

    employeeData = objdatabase.runningQuery("select * from table where field1='xxx' ")
    ' type dataTable functionality :
    - to check count : 
    employeeData.rows.count
    - to get value field :
           - if string type : 
    employeeData .Rows(index).Field(Of String)("FIELD_NAME")
           - if integer type : employeeData .Rows(index).Field(Of Integer)("FIELD_NAME")
  5. After use release the object from memory
       objdatabase.Dispose()
       objdatabase = Nothing
       GC.Collect()

[VB.NET] Random Number Function within range


Description

Random function is a function that is used to generate a random value.for a programmer is very useful random value that can be used to create a combination of string with random numbers that can produce a value to blur or protect the original value.

Not only that, a random number can be implemented in a variety of applications, for example randomize the order list of songs like winamp, then for animations contained in the application like "count down application" or even to generate some random string for security purpose like in oauth.

but for this case, i just make a random number function not random string !!.


How To


Private Function getRandomRange(ByVal lower As Integer, ByVal upper As Integer)
 Dim randomValue
 Dim objRandom As New Random
 randomValue = objRandom .Next(lower, upper)
 Return randomValue
End Function

to use this function within range just call this function like this :
- i want random number between number 1 - 9

so in VB.NET like this
* msgbox(getRandomRange(1,10)).

the question why 10 ? not 9 ? because in VB.NET upper number (in this case is 10) is not issued only 1 - 9.

[Windows] Cannot Copy Paste windows XP


Maybe this OS too old and i  recommend to move on to the next version of the OS Windows. but in some case there's a people still need this OS, mostly is developer. 

windows xp has many problem and i still using this windows for developer purpose. but lately, this os always problematic, especially on the issue of  copy and paste feature. where this feature is very vital for me. i already search the solution anywhere and there but there's nothing really solve my problem. and I finally found the solution on a forum and this is a solution if you cannot copy paste in windows XP.

the solution :


  • CTRL + W 
  • write here in RUN : C:\WINDOWS\system32\clipsrv.exe 
  • enter
  • done, now you copy paste working normally :D


[VGA] Tips memilih seri NVIDIA


Diluar sana banyak merk VGA yang beredar, tapi yang terkenal cuma 2. ya cuma 2 yakni kubu merah (AT*) dan kubu hijau (NVIDIA). untuk artikel ini saya akan lebih memilih versi kubu hijau ketimbang kubu merah karena saya sendiri pengguna kubu hijau haha . kenapa saya memilih kubu hijau ? karena kebanyakan di berbagai corporate terutama pengguna grafis yang notabene untuk process render yang tinggi kebanyakan mempercayakan hardware enginenya menggunakan NVIDIA. jadi berbanggalah kalian yang menggunakan kubu hijau hehe.

walaupun gitu masih banyak user awam yang hanya tau brandnya saja tanpa tau serinya, padahal ini sangat mempengaruhi kebutuhan dari pengguna itu sendiri, salah beli seri bisa fatal karena bisa jadi tidak bisa digunakan. berikut adalah pemaparannya :

NVIDIA saat ini memiliki 3 seri :

  • Seri GTX - Prefix GTX
          Merupakan seri tertinggi dari NVIDIA dan rata-rata sudah memiliki seluruh teknologi terbaik dari NVIDIA. lebih ditujukan untuk GAME maupun Process Grafis (seperti video editing). tentu memberikan performa terbaik :). untuk harga saya yakin anda akan berfikir dua kali, karena rata" diatas 100$ saya tidak tahu persisnya berapa, tapi buat anda yang memang maniak game akan sangat worth apalagi dirumah sudah dilengkapi seperti subwoofer atau speaker altec / LG atau headshet sennheiser akan memberi pengalaman terbaik anda dalam bermain game. Penting untuk diingat sebelum membeli pastikan Power Supply anda memenuhi syarat dalam menjalankan seri NVIDIA jenis ini karena kebutuhan Watt akan jenis ini sangat tinggi, jika tidak mencukupi anda dipastikan akan keluar uang lagi untuk membeli PowerSupply baru haha.

berikut adalah seri GTX :
GeForce GTX TITAN Z
GeForce GTX TITAN X
GeForce GTX 980 Ti
GeForce GTX 980
GeForce GTX 970
GeForce GTX 960
GeForce GTX 950 (new!)
GeForce GTX 900 Series Microsite (new!)

GeForce GTX 750 Ti


  • Seri GTS / GT - Prefix GT
     Merupakan seri yang berada dibawah seri GTX secara kebutuhan ditujukan untuk menonton film HD, 3D maupun Game. namun game disini hanya terbatas pada game kelas middle ke bawah. sangat worth jika anda mempunyai budget terbatas. untuk teknologi yang include didalamnya sudah sangat cukup walaupun masih terbilang sangat jauh ketimbang seri GTX.

berikut adalah seri GT:
GeForce GT 740
GeForce GT 730
GeForce GT 720 (new!)
GeForce GT 610

  • Seri GeForce - Prefix GeForce
      Merupakan seri paling bawah dari produk NVIDIA. jujur saya sendiri tidak merekomendasikan seri ini lebih baik ambil seri minimal GT karena fiturnya lebih baik. mungkin VGA ini digunakan untuk yg punya budget cekak hahaha (eman eman lebih baik nabung buat GT klo dapet rejeki ambil GTX haha).

berikut adalah seri GeForce 
GeForce 210.


Selanjutnya adalah pemaparan tentang teknologinya, nah ini yang sering dibuat salah kaprah buat yang mau beli VGA ini. contohnya : mas beli VGA NVIDIA donk yang 2GB (WTF ?). 2GB yang dimaksud mungkin VRAM dedicated dari VGA itu sendiri. sebenarnya ini salah, baik atau jeleknya sebuah grafis tergantung dari teknologinya. VRAM memang salah satu komponen penting dari VGA tapi tidak lebih penting dari teknologinya. pastikan jika anda membeli suatu VGA yang pertama diliat adalah Seri dan teknologinya kemudian baru liat dedicated VRAMnya. nah sekarang kita kembali lagi kebahasan awal. NVIDIA itu punya teknologi apa aja sih ? ternyata saat saya menulis ini sudah ada 22 teknologi dari NVIDIA.

 berikut listnya :

  • 3D Vision
NVIDIA 3D Vision® technology delivers stereoscopic 3D images for gamers, movie-lovers and photo enthusiasts when configured with NVIDIA GPUs, NVIDIA 3D Vision active shutter glasses, and 3D Vision-Ready display/projector. Only NVIDIA 3D Vision supports the richest array of 3D content available more than 600 3D games, Blu-ray 3D movies, 3D photos and streaming YouTube 3D videos.


  • 4K
4K revolutionizes the way you view your games by adding four times as many pixels as commonly used 1920x1080 screens, opening your eyes to rich, superbly-detailed worlds. If you have a high-end GeForce GTX PC, you’re ready for the revolution. Just plug and play and you’ll immediately receive a flawless, jaw-dropping experience.


  • Adaptive VSync
Nothing is more distracting than frame rate stuttering and screen tearing. The first tends to occur when frame rates are low, the second when frame rates are high. Adaptive VSync is a smarter way to render frames using NVIDIA Control Panel software. At high framerates, VSync is enabled to eliminate tearing. At low frame rates, it's disabled to minimize stuttering. For a superior solution, which eliminates stuttering, tearing and the addition of VSync-related input lag, see our G-SYNC technology page.


  • BatteryBoost
NVIDIA BatteryBoost™ is a new ultra efficient mode that delivers the same great 30+ FPS experience, but with up to 2x longer battery life while gaming.


  • CUDA
CUDA is a parallel computing platform and programming model invented by NVIDIA. It enables dramatic increases in computing performance by harnessing the power of the graphics processing unit (GPU).


  • DirectX 11
Microsoft DirectX is the graphics technology powering today’s most impressive games. The latest version, DirectX 11, enables the addition of advanced effects and features in NVIDIA-enhanced titles, ranging from tessellation and HBAO+, to Percentage Closer Soft Shadows and NVIDA HairWorks.


  • DirectX 12
Developers can tap into the newest graphics API to bring powerful GPU graphics to their most innovative titles. GeForce GTX 900-series GPUs support advanced DX12 features enabling new visual effects and rendering techniques for more lifelike gaming.


  • DSR
Dynamic Super Resolution renders a game at a higher, more detailed resolution and intelligently shrinks the result back down to the resolution of your monitor, giving you 4K-quality graphics on an HD screen.


  • FCAT
NVIDIA created Frame Capture Analysis Tool (FCAT) to accurately analyze GPU performance and quantify smoothness by identifying issues that simple frame-counters can miss. FCAT is able to identify dropped frames, runt frames, micro-stutter and other problems that reduce the visible smoothness of the action displayed, even when FRAPS reports a high framerate. With the help of FCAT, GeForce is able to build better GPU technology and drivers that deliver faster and smoother graphics and improve PC gaming.


  • G-SYNC
NVIDIA G-SYNC is groundbreaking new display technology that delivers the smoothest gaming experience ever. G-SYNC’s revolutionary smoothness is achieved by synchronizing display refresh rates to the GPU in your GeForce GTX-powered desktop or notebook, eliminating screen tearing and minimizing display stutter and input lag. The result: scenes appear instantly, objects look sharper, and gameplay is super smooth, giving you a stunning visual experience and a serious competitive edge.”


  • GPU Boost
GPU Boost helps extract every ounce of computing power from graphics cards, maximizing frame rates in each and every game.


  • GPU Boost 2.0
GPU Boost 2.0 extracts every ounce of computing power from graphics cards, maximizing frame rates in each and every game. Compared to the original GPU Boost, GPU Boost 2.0 is faster and more flexible, giving users more control over its configuration.


  • HairWorks
NVIDIA HairWorks combines the power of NVIDIA GeForce GTX GPUs with DirectX 11 tessellation technology to add hundreds of thousands of dynamic, realistic hairs to characters, creatures, and game worlds.


  • HBAO+
HBAO+ improves upon existing Ambient Occlusion techniques to add richer, more detailed, more realistic shadows around objects that occlude rays of light. Compared to previous techniques, HBAO+ is faster, more efficient, and significantly better.


  • MFAA
With the launch of Maxwell we are introducing the world to Multi-Frame Anti-Aliasing (MFAA). This new, Maxwell-exclusive anti-aliasing technique improves edge quality with a minimal performance cost, and helps you enjoy anti-aliased games at ultra high resolutions like 4K.


  • Optimus
NVIDIA Optimus technology intelligently optimizes your notebook PC, providing the outstanding graphics performance you need, when you need it, all the while extending battery life for longer enjoyment.


  • PhysX
Without accurate physics simulation even the most beautiful game feels static and lifeless. PhysX taps into the power of NVIDIA’s GeForce GTX GPUs to create incredible effects and scenes filled with dynamic destruction, particle based fluids, and life-like animation. Reviewers attest, games like Assassin’s Creed IV: Black Flag, Batman: Arkham Origins, Borderlands 2, and Metro: Last Light are better with GPU-accelerated PhysX effects enabled.


  • SLI
Upgrade your rig with a second NVIDIA GeForce GTX GPU to enable SLI, the system turbocharger of choice for gamers, which enables everyone’s favorite titles to be played at the highest screen resolutions with every setting maxed out. NVIDIA SLI supports the use of up to 4 GPUs, and thanks to FCAT, SLI is certified by independent press as fast, smooth and responsive.


  • Surround
With the power of GeForce GPUs, gamers are able to combine up to five displays to create the most immersive gaming environment possible. Here, you can leverage the latest NVIDIA display technologies including G-SYNC and 3D Vision and run them at resolutions up to 4K!


  • TXAA
TXAA anti-aliasing creates a smoother, clearer image than any other anti-aliasing solution by combining high-quality MSAA multisample anti-aliasing, post processes, and NVIDIA-designed temporal filters.


  • Virtual Reality
With GeForce Experience and GameWorks VR, GeForce GTX delivers the ultimate graphics platform for Virtual Reality.


  • VXGI
Voxel Global Illumination (VXGI) is a stunning advancement, delivering incredibly realistic lighting, shading and reflections to next-generation games and game engines.


wuih bejubel ya teknologinya ? hahaha semua ada di seri GTX. enjoy your game :D


Tag Search :
tips memilih seri gforce
seri gforce terbaik
seri vga nvidia
seri nvidia terbaik
seri gforce terbaik
macam macam seri nvidia
teknologi vga gforce
teknologi vga nvidia



[VB.NET] Upload file to PHP web page

Description
       i will teach you how to upload file and passing parameter at the same time from vb.net to PHP web page. it's not using FTP protocol but use standart protocol (80). don't worry about difficulty i will explain to you.

HowTo
     1. First you must prepare webserver (apache) and turn it on. i won't explain how to install apache.
     2. write the php code for upload and give name for example upload.php and create folder give name uploads. write php script for upload :
$target_dir = "uploads/";
print_r($_FILES);
//print_r($_POST);
print_r($_REQUEST);
//echo $_POST["nama"];
$target_file = $_FILES['fileToUpload']['tmp_name'];
 if(move_uploaded_file($target_file, $target_dir.'filesukses'))
 {
 echo "Success";
 }
 else
 {
 echo "Failure";
 }
3. open vb.net create one project , add one button on form and at click events write this code :
HttpUploadFile("http://localhost/upload/upload.php?parameter1=""value1""&parameter2=""value2""", "C:\myfileupload.txt", "fileToUpload", "multipart/form-data")
4. add import :
Imports System.IO
Imports System.Net
Imports System.Text
5. add private function
Private Sub HttpUploadFile( _
    ByVal uri As String, _
    ByVal filePath As String, _
    ByVal fileParameterName As String, _
    ByVal contentType As String)

        Dim boundary As String = "---------------------------" & DateTime.Now.Ticks.ToString("x")
        Dim newLine As String = System.Environment.NewLine
        Dim boundaryBytes As Byte() = Encoding.ASCII.GetBytes(newLine & "--" & boundary & newLine)
        Dim request As Net.HttpWebRequest = Net.WebRequest.Create(uri)
        request.ContentType = "multipart/form-data; boundary=" & boundary
        request.Method = "POST"
        request.KeepAlive = True
        request.Credentials = Net.CredentialCache.DefaultCredentials
        Using requestStream As IO.Stream = request.GetRequestStream()
            Dim formDataTemplate As String = "Content-Disposition: form-data; name=""{0}""{1}{1}{2}"
            requestStream.Write(boundaryBytes, 0, boundaryBytes.Length)


            Dim headerTemplate As String = "Content-Disposition: form-data; name=""{0}""; filename=""{1}""{2}Content-Type: {3};"
            Dim header As String = String.Format(headerTemplate, fileParameterName, filePath, newLine, contentType)
            MsgBox(header)
            Dim headerBytes As Byte() = Encoding.UTF8.GetBytes(header)
            requestStream.Write(headerBytes, 0, header.Length)

            Using fileStream As New IO.FileStream(filePath, IO.FileMode.Open, IO.FileAccess.Read)
                Dim buffer(4096) As Byte
                Dim bytesRead As Int32 = fileStream.Read(buffer, 0, buffer.Length)
                Do While (bytesRead > 0)
                    requestStream.Write(buffer, 0, bytesRead)
                    bytesRead = fileStream.Read(buffer, 0, buffer.Length)
                Loop

            End Using
            Dim trailer As Byte() = Encoding.ASCII.GetBytes(newLine & "--" + boundary + "--" & newLine)
            requestStream.Write(trailer, 0, trailer.Length)
        End Using
        Dim response As Net.WebResponse = Nothing
        Try
            response = request.GetResponse()
            Using responseStream As IO.Stream = response.GetResponseStream()
                Using responseReader As New IO.StreamReader(responseStream)
                    Dim responseText = responseReader.ReadToEnd()
                    MsgBox(responseText)
                End Using
            End Using
        Catch exception As Net.WebException
            response = exception.Response
            If (response IsNot Nothing) Then
                Using reader As New IO.StreamReader(response.GetResponseStream())
                    Dim responseText = reader.ReadToEnd()
                    Diagnostics.Debug.Write(responseText)
                End Using
                response.Close()
            End If
        Finally
            request = Nothing
        End Try
    End Sub
6. click the button and you will see myfileupload.txt already uploaded to webserver and the webserver give some response in text. the response is print_r from array $_FILES and print_r from array $_request.

simple right ? :)

[PHP] what is __ means in PHP ?


Description
     Sometime in php we often seen __ (underscore) character in naming methods. why they use that ??
that's magic methods !!. magic method in php always start with underscore __. for example :

public function __sleep()
{
     //to do here
}

you cannot use this function name in any classes unless you want this magic method assosiate with your classes. so when we need magic method ? it's depend on what your need. if  you not need this magic method don't use them.

PHP have several magic method, here's the list :

__construct()
is the method name for the constructor. The constructor is called on an object after it has been created.
class CAR
{
    public $brand = '';
    public function __construct($name) 
    {
        $this->brand = $name ;    }
}

$person = new CAR ( "honda" );
echo $person->brand;

__destruct()
Destructors called during the script shutdown have HTTP headers already sent. Attempting to throw an exception from a destructor can causes a fatal error.
class CAR
{
    public function __destruct() 
    {
        print "destroy the class";    
    }
}

$person = new CAR ();

__call()
this methods will call another function that inaccessible property like private / protected. 
namespace test\foo;

class A
{
    public static function __callStatic($method, $args)
    {
        echo __METHOD__ . "\n";

        return call_user_func_array(__CLASS__ . '::' . $method, $args);
    }

    protected static function foo()
    {
        echo __METHOD__ . "\n";
    }
}

A::foo();

__callStatic()
class A {
    public function __call($method, $parameters) {
        echo "I'm the __call() magic method".PHP_EOL;
    }

    public static function __callStatic($method, $parameters) {
        echo "I'm the __callStatic() magic method".PHP_EOL;
    }
}

class B extends A {
    public function bar() {
        A::foo();
    }
}

A::foo();
(new A)->foo();

B::bar();
(new B)->bar();

Result :
I'm the __callStatic() magic method
I'm the __call() magic method
I'm the __callStatic() magic method
I'm the __call() magic method

__get()
is utilized for reading data from inaccessible properties.

__set()
is run when writing data to inaccessible properties.

__isset()

__unset()

__sleep()

__wakeup()

__toString()

__invoke()

__set_state()

__clone()

__debugInfo()

*Note :
All example i taken from google (mostly from stackoverflow). thanks to the owner whose have this code :).

[Python] Execute Python Script in VB.NET


Description
     Sometime in VB.NET we execute some shell script from third party like perl / phyton / other because it's may be have more advantage feature than .NET. this tutorial will help you to make python script can be execute from VB.NET

HowTo
1. Download Python Here (Official)
2. Write your python code , for example : print("Hello world python !!") in text file and save to .py
3. Create project at VB.NET, drag component 1 button and 1 textbox into form.
4. Double click button1, at event click button1 write this code 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim proc As Process = New Process
        proc.StartInfo.FileName = "C:\Python34\python.exe" 'Default Python Installation
        proc.StartInfo.Arguments = pathmypythonfile.py
        proc.StartInfo.UseShellExecute = False 'required for redirect.
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden 'don't show commandprompt.
        proc.StartInfo.CreateNoWindow = True
        proc.StartInfo.RedirectStandardOutput = True 'captures output from commandprompt.
        proc.Start()
        AddHandler proc.OutputDataReceived, AddressOf proccess_OutputDataReceived
        proc.BeginOutputReadLine()
        proc.WaitForExit()

        TextBox1.Text = Value
    End Sub

    Public sub proccess_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
        On Error Resume Next
        If e.Data = "" Then
        Else
            Value = e.Data
        End If
    End sub 

5. Create module file, and write this variable global :
    Module module
           Public Value As String
    End Module

6. Running the application, if textbox1 have populated with some string then your code was success.

[VB.NET] Embed Flash Player (.swf)


Description
     this tutorial will help you to embed flash player (swf) to VB.NET. it's simple just follow the step below.

HowTo
     1. Install Shockwave Player Here
     2. Add Component on toolbox by right click and choose item, after that select COM Components tabs then checklist Shockwave Flash Object and click ok.
     3. New component appear in toolbox (icon flash), just drag and drop it into form and give name "flashPlayer"
     4. Test the flash player by add source file (.swf file). use this code on the form load :
         
         flashPlayer.Movie = My.Application.Info.DirectoryPath & "\fileflash.swf"


if still not understand may be watch this video is the solution :) , thanks for the uploader.