chào các bạn,mình lập trình như thế này trên visual studio 2008,nhưng k biết lỗi gì mà mình mô phỏng nó báo lỗi,các bạn giúp mình với
"Public Class Form1
Private Sub Nut_thoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_thoat.Click
Form2.ShowDialog()
End Sub
Private Sub HướngDẫnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HướngDẫnToolStripMenuItem.Click
End Sub
Private Sub ThôngTinToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThôngTinToolStripMenuItem.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If SerialPort1.IsOpen Then SerialPort1.Close()
SerialPort1.Open()
End Sub
Private Sub Button_phai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_phai.Click
SerialPort1.Write("d")
Label2.Text = ("Robot đang rẽ phải")
End Sub
Private Sub Button_toi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_toi.Click
SerialPort1.Write("w")
Label2.Text = ("Robot đang đi tới")
End Sub
Private Sub Button_trai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_trai.Click
SerialPort1.Write("a")
Label2.Text = ("Robot đang rẽ trái")
End Sub
Private Sub Button_dung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_dung.Click
SerialPort1.Write("j")
Label2.Text = ("Robot đã dừng")
End Sub
Private Sub Button_lui_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_lui.Click
SerialPort1.Write("s")
Label2.Text = ("Robot đang đi lui")
End Sub
Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
If (SerialPort1.IsOpen) Then SerialPort1.Close()
End Sub
Private Sub TớiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TớiToolStripMenuItem.Click
SerialPort1.Write("w")
Label2.Text = ("Robot đang đi tới")
End Sub
Private Sub LuiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LuiToolStripMenuItem.Click
SerialPort1.Write("s")
Label2.Text = ("Robot đang đi lui")
End Sub
Private Sub PhảiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhảiToolStripMenuItem.Click
SerialPort1.Write("d")
Label2.Text = ("Robot đang rẽ phải")
End Sub
Private Sub TráiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TráiToolStripMenuItem.Click
SerialPort1.Write("a")
Label2.Text = ("Robot đang rẽ trái")
End Sub
Private Sub DừngToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DừngToolStripMenuItem.Click
SerialPort1.Write("j")
Label2.Text = ("Robot đã dừng")
End Sub
Private Sub ThôngTinToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThôngTinToolStripMenuItem1.Click
MsgBox(" Chương trình điều khiển từ xa phiên bản 1.0 này là Đồ án môn học Hệ thống Cơ điện tử, do sinh viên Nguyễn Quốc Vũ - lớp 06CDT2 - ngành Cơ Điện Tử - Trường Đại Học Bách Khoa Đà Nẵng viết. ")
End Sub
Private Sub CáchĐiềuKhiểnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CáchĐiềuKhiểnToolStripMenuItem.Click
MsgBox(" Bạn có thể điều khiển Robot bằng bàn phím trên máy tính: Ctrl + W: đi tới ; Ctrl + S: đi lui; Ctrl + A: sang trái ; Ctrl + D: sang phải ; Cltr + J: dừng ; Cltr + K: Camera quay trái ; Cltr + L: Camera quay phải")
End Sub
Private Sub PhôngNềnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhôngNềnToolStripMenuItem.Click
ColorDialog1.ShowDialog()
Me.BackColor = ColorDialog1.Color
End Sub
Private Sub MàuNútNhấnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MàuNútNhấnToolStripMenuItem.Click
ColorDialog1.ShowDialog()
Button_cam_phai.BackColor = ColorDialog1.Color
Button_cam_trai.BackColor = ColorDialog1.Color
Button_trai.BackColor = ColorDialog1.Color
Button_phai.BackColor = ColorDialog1.Color
Button_toi.BackColor = ColorDialog1.Color
Button_lui.BackColor = ColorDialog1.Color
Button_dung.BackColor = ColorDialog1.Color
Button_thoat.BackColor = ColorDialog1.Color
End Sub
Private Sub Button_cam_trai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_cam_trai.Click
SerialPort1.Write("k")
Label2.Text = ("Camera đang quay trái")
End Sub
Private Sub Button_cam_phai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_cam_phai.Click
SerialPort1.Write("l")
Label2.Text = ("Camera đang quay phải")
End Sub
Private Sub CameraTráiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CameraTráiToolStripMenuItem.Click
SerialPort1.Write("k")
Label2.Text = ("Camera đang quay trái")
End Sub
Private Sub CameraPhảiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CameraPhảiToolStripMenuItem.Click
SerialPort1.Write("l")
Label2.Text = ("Camera đang quay phải")
End Sub
End Class
Public Class Form2
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Nut_khong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nut_khong.Click
Me.Close()
End Sub
Private Sub Nut_co_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nut_co.Click
End
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Beep()
End Sub
End Class
"Public Class Form1
Private Sub Nut_thoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_thoat.Click
Form2.ShowDialog()
End Sub
Private Sub HướngDẫnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HướngDẫnToolStripMenuItem.Click
End Sub
Private Sub ThôngTinToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThôngTinToolStripMenuItem.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If SerialPort1.IsOpen Then SerialPort1.Close()
SerialPort1.Open()
End Sub
Private Sub Button_phai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_phai.Click
SerialPort1.Write("d")
Label2.Text = ("Robot đang rẽ phải")
End Sub
Private Sub Button_toi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_toi.Click
SerialPort1.Write("w")
Label2.Text = ("Robot đang đi tới")
End Sub
Private Sub Button_trai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_trai.Click
SerialPort1.Write("a")
Label2.Text = ("Robot đang rẽ trái")
End Sub
Private Sub Button_dung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_dung.Click
SerialPort1.Write("j")
Label2.Text = ("Robot đã dừng")
End Sub
Private Sub Button_lui_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_lui.Click
SerialPort1.Write("s")
Label2.Text = ("Robot đang đi lui")
End Sub
Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
If (SerialPort1.IsOpen) Then SerialPort1.Close()
End Sub
Private Sub TớiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TớiToolStripMenuItem.Click
SerialPort1.Write("w")
Label2.Text = ("Robot đang đi tới")
End Sub
Private Sub LuiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LuiToolStripMenuItem.Click
SerialPort1.Write("s")
Label2.Text = ("Robot đang đi lui")
End Sub
Private Sub PhảiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhảiToolStripMenuItem.Click
SerialPort1.Write("d")
Label2.Text = ("Robot đang rẽ phải")
End Sub
Private Sub TráiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TráiToolStripMenuItem.Click
SerialPort1.Write("a")
Label2.Text = ("Robot đang rẽ trái")
End Sub
Private Sub DừngToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DừngToolStripMenuItem.Click
SerialPort1.Write("j")
Label2.Text = ("Robot đã dừng")
End Sub
Private Sub ThôngTinToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ThôngTinToolStripMenuItem1.Click
MsgBox(" Chương trình điều khiển từ xa phiên bản 1.0 này là Đồ án môn học Hệ thống Cơ điện tử, do sinh viên Nguyễn Quốc Vũ - lớp 06CDT2 - ngành Cơ Điện Tử - Trường Đại Học Bách Khoa Đà Nẵng viết. ")
End Sub
Private Sub CáchĐiềuKhiểnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CáchĐiềuKhiểnToolStripMenuItem.Click
MsgBox(" Bạn có thể điều khiển Robot bằng bàn phím trên máy tính: Ctrl + W: đi tới ; Ctrl + S: đi lui; Ctrl + A: sang trái ; Ctrl + D: sang phải ; Cltr + J: dừng ; Cltr + K: Camera quay trái ; Cltr + L: Camera quay phải")
End Sub
Private Sub PhôngNềnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhôngNềnToolStripMenuItem.Click
ColorDialog1.ShowDialog()
Me.BackColor = ColorDialog1.Color
End Sub
Private Sub MàuNútNhấnToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MàuNútNhấnToolStripMenuItem.Click
ColorDialog1.ShowDialog()
Button_cam_phai.BackColor = ColorDialog1.Color
Button_cam_trai.BackColor = ColorDialog1.Color
Button_trai.BackColor = ColorDialog1.Color
Button_phai.BackColor = ColorDialog1.Color
Button_toi.BackColor = ColorDialog1.Color
Button_lui.BackColor = ColorDialog1.Color
Button_dung.BackColor = ColorDialog1.Color
Button_thoat.BackColor = ColorDialog1.Color
End Sub
Private Sub Button_cam_trai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_cam_trai.Click
SerialPort1.Write("k")
Label2.Text = ("Camera đang quay trái")
End Sub
Private Sub Button_cam_phai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_cam_phai.Click
SerialPort1.Write("l")
Label2.Text = ("Camera đang quay phải")
End Sub
Private Sub CameraTráiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CameraTráiToolStripMenuItem.Click
SerialPort1.Write("k")
Label2.Text = ("Camera đang quay trái")
End Sub
Private Sub CameraPhảiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CameraPhảiToolStripMenuItem.Click
SerialPort1.Write("l")
Label2.Text = ("Camera đang quay phải")
End Sub
End Class
Public Class Form2
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Nut_khong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nut_khong.Click
Me.Close()
End Sub
Private Sub Nut_co_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nut_co.Click
End
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Beep()
End Sub
End Class