Re: [VB2008] 並未將物件參考設定為物件的執行個體?
※ 引述《JlTsai (紙片人 )》之銘言:
: 會出現 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
: 請問該如何修改呢??
雖然有點久遠的文章了...
不過這問題之後是如何解決的呢...?
買了一樣的書遇到一樣的問題了 Orz
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.170.3.13
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章