您好,我需要知道如何使用vb.net中的圖像ID加載圖像像localhost/2。我已經設置了服務器,但我需要使用文本框輸入id並加載圖像。任何人都可以幫助我嗎?請注意,我正在使用一個按鈕來將ID輸入到文本框後加載圖像。 這是我走到這一步:如何從服務器使用圖像ID加載圖像?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = webDownloadImage("http://localhost/", True, "C:\temp.jpg")
End Sub
Public Function webDownloadImage(ByVal Url As String, Optional ByVal saveFile As Boolean = False, Optional ByVal location As String = "C:\") As Image
Dim webClient As New System.Net.WebClient
Dim bytes() As Byte = webClient.DownloadData(Url)
Dim stream As New IO.MemoryStream(bytes)
If saveFile Then My.Computer.FileSystem.WriteAllBytes(location, bytes, False)
Return New System.Drawing.Bitmap(stream)
End Function
請說明您迄今爲止所做的工作。 – kaonashi
@brcm在那裏我加了 – Pepperrika
只是爲了確認,你需要在URL中追加ID?例如:'ID = 2'和'URL =「http:// localhost/2」'? – kaonashi