[Windows Mobile Development and Hacking General] E-P-S:
IT WORKS

Now it works. (thx to "Useless User" from "PPC-Welt")

SUPER SUPER SUPER.

Here's the right code:

Imports System.IO

Public Class Form1

Dim X As Integer
Dim APPPATH As String
Dim GlobalGPSSTREAM As String
Dim txt As IO.StreamWriter

Private Delegate Sub SetGlobalGPSStreamDgt(ByVal text As String)
Private Sub SetGlobalGPSSTREAM(ByVal text As String)
ListAdd(text, True)
End Sub

Private Sub ShowVerNumber()

'App.Path und App.Minor etc Test

APPPATH = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules(0).FullyQualifiedName) & "\"
txt = New IO.StreamWriter(APPPATH + "testfile.txt", True)
ListAdd("Datenfile: " + APPPATH + "testfile.txt", False)

Me.Text = "GPRSGPS V" + GetType(Form1).Assembly.GetName.Version.ToString()
'ListAdd("Progfile: " + Me.Text, False)
'Me.Text = Path.GetDirectoryName(Assembly.GetExecutingAssembl y().GetModules(0).FullyQualifiedName) & "/"

'App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & App.EXEName

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Listbox1.Items.Clear()
'TextBox1.Items.Clear()

ShowVerNumber()

SerialPort1.Encoding = System.Text.Encoding.Default
'SerialPort1.Encoding = System.Text.Encoding.ASCII
End Sub

Private Sub ListAdd(ByVal Ttext As String, Optional ByVal Write2File As Boolean = False)
'Den Focus auf den zuletzt inder Lisbox hinzugefügten Datensatz legen
'ebenfalls die Zeile in die oben deklarierte Datei speichern.
If Ttext <> "" And Len(Ttext) > 0 Then

Try
With ListBox1
.Items.Add(Ttext)
If .Items.Count > 0 Then
.SelectedIndex = .Items.Count - 1
End If
End With

'Wenn Write2File=True dann soll er den TText ins File schreiben

If Write2File = True Then txt.WriteLine(Ttext)
Catch e As Exception
'MsgBox(e.ToString)
txt.WriteLine(e.ToString)
If X = 10 Then 'Bei 10 Fehlern Text File speichern.
txt.Close()
Application.Exit()
End If
End Try

End If
End Sub

Private Sub GetGSM_STATUS()
'Anzeigen der aktuellen Mobilfunk-Signal-Stärke
X = X + 1 'Zeilenzähler
ListAdd(Microsoft.WindowsMobile.Status.SystemState.PhoneSignalStrength, True)
End Sub

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim newLine As String = SerialPort1.ReadLine
Me.Invoke(New SetGlobalGPSStreamDgt(AddressOf SetGlobalGPSSTREAM), New Object() {newLine})
End Sub

Private Sub BTN_STOP_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_STOP.Click

txt.Close()
Application.Exit()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim txt As IO.StreamWriter = New IO.StreamWriter("datei.txt"), False, System.Text.Encoding.Default)
'txt.WriteLine("blablabla")
'txt.WriteLine("")
'txt.Close()
End Sub

Private Sub BTN_COM_OPEN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_COM_OPEN.Click
If SerialPort1.IsOpen = True Then SerialPort1.Close()

'SerialPort1.PortName = Trim("COM" + Trim(Str(NumericUpDown1.Value)) + ":")
SerialPort1.PortName = Trim("COM" + Trim(Str(NumericUpDown1.Value)))
'ListAdd("COMPORT Setting: " + SerialPort1.PortName, False)
Try
SerialPort1.Open()
Catch Ausnahme As IOException
MsgBox(Ausnahme.Message, MsgBoxStyle.Critical, "Fehler !")
End Try

'MsgBox(SerialPort1.PortName)

End Sub

Private Sub BTN_COM_CLOSE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_COM_CLOSE.Click
If SerialPort1.IsOpen = True Then SerialPort1.Close()
'ListAdd("COMPORT geschlossen", False)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If SerialPort1.IsOpen = True Then
Label1.BackColor = Color.Green
Else
Label1.BackColor = Color.Red
End If
End Sub

Private Sub BTN_WriteHallo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_WriteHallo.Click
'ListAdd("Hallo", False)
End Sub

End Class