Re: [VB2008] 並未將物件參考設定為物件的執行個體?

看板Visual_Basic作者 (5858)時間13年前 (2012/07/30 00:10), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《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
文章代碼(AID): #1G5M1zaU (Visual_Basic)
文章代碼(AID): #1G5M1zaU (Visual_Basic)