Public Class Form1
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Form2.Label1.Text = "------"
Button1.Enabled = True
Button2.Enabled = False
ComboBox1.Enabled = True
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.Text = ""Then
MsgBox("ComPort Kutusu Boş Olamaz! Bir ComPort Seçiniz", MsgBoxStyle.Exclamation, "Uyarı")
ComboBox1.Focus()
Else
Form2.SerialPort1.PortName = ComboBox1.Text
Form2.SerialPort1.Open()
ComboBox1.Enabled = False
Button2.Enabled = True
Button1.Enabled = False
Form2.Show()
Form2.Select()
EndIf
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.SerialPort1.Close()
ComboBox1.Enabled = True
Button1.Enabled =True
Button2.Enabled = False
EndSub
EndClass
Imports System.IO
Imports System.Windows.Forms
PublicClass Form2
PrivateSub Form2_KeyDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.KeyEventArgs) HandlesMe.KeyDown
If SerialPort1.IsOpen = FalseThen
MsgBox("ComPort Kapalı! Başla Düğmesi ile ComPortu Açmalısınız?", MsgBoxStyle.Exclamation, "Uyarı")
ExitSub
Else
If e.KeyCode = Keys.Up Then
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
Label1.Text = " UP "
SerialPort1.Write(Label1.Text)
EndIf
If e.KeyCode = Keys.Right Then
PictureBox2.Visible = True
PictureBox1.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
Label1.Text = " RIGHT > "
SerialPort1.Write(Label1.Text)
EndIf
If e.KeyCode = Keys.Down Then
PictureBox3.Visible = True
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox4.Visible = False
Label1.Text = " DOWN "
SerialPort1.Write(Label1.Text)
EndIf
If e.KeyCode = Keys.Left Then
PictureBox4.Visible = True
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
Label1.Text = " < LEFT "
SerialPort1.Write(Label1.Text)
EndIf
EndIf
EndSub
EndClass