Hallo,
kann mit jemand sagen warum VB die Antwort vom Handz nicht rausgibt ?
wo ist mein fehler?
Imports System.IO
Public Class Form1
Dim WithEvents serialport As New IO.Ports.SerialPort
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
ListBox1.Items.Add(My.Computer.Ports.SerialPortNames(i))
Next
Button2.Enabled = False
End Sub
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If serialport.IsOpen Then
serialport.Close()
End If
Try
With serialport
.PortName = ListBox1.Text
.BaudRate = 115200
.Parity = Ports.Parity.None
.DataBits = 8
.StopBits = Ports.StopBits.One
End With
serialport.Open()
Button1.Enabled = False
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button3\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
serialport.Write("AT+CSQ" & vbCrLf)
With txtdatareceived
.appendtext(txtdatatosend.text & vbCrLf)
End With
txtdatatosend.text = String.Empty
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub SerialPort1\_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
MsgBox("da kommt was")
End Sub
End Class
\>Imports System.IO
Public Class Form1
Dim WithEvents serialport As New IO.Ports.SerialPort
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
ListBox1.Items.Add(My.Computer.Ports.SerialPortNames(i))
Next
Button2.Enabled = False
End Sub
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If serialport.IsOpen Then
serialport.Close()
End If
Try
With serialport
.PortName = ListBox1.Text
.BaudRate = 115200
.Parity = Ports.Parity.None
.DataBits = 8
.StopBits = Ports.StopBits.One
End With
serialport.Open()
Button1.Enabled = False
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub Button3\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
serialport.Write("AT+CSQ" & vbCrLf)
With txtdatareceived
.appendtext(txtdatatosend.text & vbCrLf)
End With
txtdatatosend.text = String.Empty
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub SerialPort1\_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
MsgBox("da kommt was")
End Sub
End Class