NBATMAN
Üye
- Katılım
- 7 Şub 2008
- Mesajlar
- 136
- Puanları
- 1
Benim kullandığım kodlar aşağıdaki gibi,umarım ihtiyacı olana faydalı olur.
Vb 6.0 için
Comport açma (çalıştırma) için;
Private Sub Command1_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Else
MSComm1.PortOpen = False
End If
End sub
Comport kapatma(durdurma) için;
Private Sub Command2_Click()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
Else
MSComm1.PortOpen = True
End If
End sub
Vb2008 için
Comport açma (çalıştırma) için;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.PortName = Label1.Text
Try
If SerialPort1.IsOpen = False Then
SerialPort1.Open()
Label2.Text = Label1.Text + " " + "is AVAILABLE"
Else
SerialPort1.Close()
End If
Catch ex As Exception
MsgBox(ex.Message)
Label2.Text = Label1.Text + " " + "is NOT AVAILABLE"
Exit Sub
End Try
End Sub
Comport kapatma(durdurma) için;
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SerialPort1.PortName = Label1.Text
Try
If SerialPort1.IsOpen = True Then
SerialPort1.Close()
Label2.Text = Label1.Text + " " + "is NOT AVAILABLE"
Else
SerialPort1.Open()
End If
Catch ex As Exception
MsgBox(ex.Message)
Label2.Text = Label1.Text + " " + "is AVAILABLE"
Exit Sub
End Try
End Sub
Vb 6.0 için
Comport açma (çalıştırma) için;
Private Sub Command1_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
Else
MSComm1.PortOpen = False
End If
End sub
Comport kapatma(durdurma) için;
Private Sub Command2_Click()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
Else
MSComm1.PortOpen = True
End If
End sub
Vb2008 için
Comport açma (çalıştırma) için;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.PortName = Label1.Text
Try
If SerialPort1.IsOpen = False Then
SerialPort1.Open()
Label2.Text = Label1.Text + " " + "is AVAILABLE"
Else
SerialPort1.Close()
End If
Catch ex As Exception
MsgBox(ex.Message)
Label2.Text = Label1.Text + " " + "is NOT AVAILABLE"
Exit Sub
End Try
End Sub
Comport kapatma(durdurma) için;
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SerialPort1.PortName = Label1.Text
Try
If SerialPort1.IsOpen = True Then
SerialPort1.Close()
Label2.Text = Label1.Text + " " + "is NOT AVAILABLE"
Else
SerialPort1.Open()
End If
Catch ex As Exception
MsgBox(ex.Message)
Label2.Text = Label1.Text + " " + "is AVAILABLE"
Exit Sub
End Try
End Sub