你好,我需要知道如何在vb.net (如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
发布于 2015-07-10 03:41:03
这就是您可以做的,只需将textbox - TextBox1.Text
的值附加到您的URL中,只需确保它有一个值就行了。
PictureBox1.Image = webDownloadImage("localhost/" & TextBox1.Text, True, "C:\temp.jpg")
https://stackoverflow.com/questions/31331425
复制相似问题