Mengirim data atau mengambil data dari HTML dengan menggunakan system.net.webclient

15 02 2008

Berikut codenya

====== < PUT RIGHT AT TOP OF MODULE
Imports System
Imports System.text
======= < PUT RIGHT AT TOP OF MODULE
Function DownloadPage(ByVal sCompleteURL As String) As String
Dim wDownload As System.Net.WebClient = New System.Net.WebClient()
Dim bHTML As Byte() = wDownload.DownloadData(sCompleteURL)
Dim sWebPage As String = Encoding.ASCII.GetChars(bHTML)
Return sWebpage
End Function
Function PostData(ByVal sAddress As String, ByVal sData As String) As String
Dim wUpload As Net.WebClient = New System.Net.WebClient()
Dim bPostArray As Byte() = Encoding.ASCII.GetBytes(sData)
wUpload.Headers.Add("Content-Type", "application/x-www-form-urlencoded" & Chr(10) & Chr(13))
Dim bResponse As Byte() = wUpload.UploadData(sAddress, "POST", bPostArray)
Dim sWebPage As String = Encoding.ASCII.GetChars(bResponse)
Return sWebPage
End Function

dan format data yang akan dikirim adalah
variabel1=nilai1&variabel2=nilai2


Tindakan

Information

Tinggalkan komentar