Re: [VB2008] 並未將物件參考設定為物件的執行個體?
會出現 Exception的程式碼似乎在這一段
上篇推文中 P大建議我將 Dim a as xxx = new xx()
但是我修改完會出現錯誤 例如以下紅色字
Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles timer1.Tick
Dim port As Integer = 5000
Try
' 複雜影像至剪貼簿(Clipboard)
SendMessage(hwnd, WM_CAP_EDIT_COPY, 0, 0)
' 自剪貼簿(Clipboard)取得物件
Dim data As IDataObject = Clipboard.GetDataObject()
將上行改成
Dim data As IDataObject = New Clipboard.GetDataObject()
則會出現 型別'Clipboard.GetDataObject'未定義
' 建立記憶體的資料流
Dim memStream As New System.IO.MemoryStream()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
Dim image As Image =
CType((data.GetData(GetType(System.Drawing.Bitmap))), Image)
' 將影像依指定格式儲存至指定的資料流
image.Save(memStream, ImageFormat.Jpeg)
End If
' 將影像依指定格式儲存至指定的資料流
picLocal.Image.Save(memStream, ImageFormat.Jpeg)
' 回傳記憶體資料流之位元組陣列
Dim buffer As Byte() = memStream.GetBuffer
' 建立用戶端TcpClient
Dim tcpClient As New TcpClient(txtHost.Text, port)
' 取得用戶端的輸出入串流
clientStream = tcpClient.GetStream()
' 建立BinaryWriter
Dim binarywriter As New BinaryWriter(clientStream)
binarywriter.Write(buffer)
binarywriter.Flush()
binarywriter.Close()
memStream.Flush()
memStream.Close()
clientStream.Flush()
clientStream.Close()
tcpClient.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
請問該如何修改呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.127.205.249
推
09/04 16:34, , 1F
09/04 16:34, 1F
→
09/04 16:34, , 2F
09/04 16:34, 2F
→
09/04 16:35, , 3F
09/04 16:35, 3F
→
09/04 16:36, , 4F
09/04 16:36, 4F
→
09/04 16:37, , 5F
09/04 16:37, 5F
→
09/04 16:38, , 6F
09/04 16:38, 6F
→
09/04 16:38, , 7F
09/04 16:38, 7F
推
09/04 16:50, , 8F
09/04 16:50, 8F
→
09/04 16:50, , 9F
09/04 16:50, 9F
推
09/04 21:09, , 10F
09/04 21:09, 10F
→
09/04 21:11, , 11F
09/04 21:11, 11F
→
09/04 21:12, , 12F
09/04 21:12, 12F
→
09/04 21:12, , 13F
09/04 21:12, 13F
推
09/04 21:13, , 14F
09/04 21:13, 14F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 2 之 3 篇):