VB.NET 宣告的問題!!

Dim WithEvents objPort As SerialNET.Port

這行意思是什麼???

1 Answer

Rating
  • Wow
    Lv 6
    1 decade ago
    Favorite Answer

    簡單說

    這程式應該有宣告名稱空間

    例如

    Imports SerialNet.Port

    然後這行物件宣告

    Dim WithEvents objPort As SerialNET.Port

    這樣就可以參考物件

    例如

    Dim WithEvents objPort As SerialNET.Port

    objPort = New SerialNET.Port

    objPort.ComPort = 1

    objPort.BaudRate = 19200

    objPort.BufferSize = 250

    objPort.Timeout = 0

    objPort.DTR = False

    objPort.RTS = False

    objPort.StartTrigger = "M"

    objPort.EndTrigger = Chr(10)

    WithEvents

    因為 objPort 宣告為物件變數

    當用 New 產生類別實體存放在變數之後

    這個實體可以告知設定的提供者事件已發生來引發指定的事件

Still have questions? Get your answers by asking now.