Pablo Software Solutions
2.  In VB Select File New and select a Windows type application.
3.  From the Toolbox, Drag a SerialPort Component onto Form1.
1. You will need to get a free copy of Visual Basic 2005 from Microsoft.  Just click the image below to go to the site.  Come back here after you have installed it.
4. You should see the component named SerialPort1 below Form1.
5.  Now add a Button and Label to Form1 from the Toolbar
6. Double Click on Button1 and the code window will open.  The following is the code to open the serial port connection with Bluetooth to the NXT.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            With SerialPort1
                .PortName =
"COM9"  '<<<< Change this number for your computer
                .BaudRate = 96000
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                .ReadTimeout = 300 
                .WriteTimeout = 300 '300ms
            End With
            Label1.Text =
        Catch ex As Exception
End Try
    End Sub
7.  The easiest way to make sure Bluetooth communications has been established between the PC and the NXT is to initally connect the two with the standard LEGO Mindstorms software.  The connection window will look like this.   I happen to have two NXTs so there is more showing than you might have.  After you get this to work, close the LEGO software completly.  You should only need to do this once because the connection will be remembered.
8.  Make sure the NXT is turned on.  Either on your desktop or in the control panel you will have a Bluetooth Icon like the one below.  Click on it and look at the connections.
9.  You should see at least the NXT device listed as Passkey enabled.
10.  Select the COM ports tab and you should see the Outgoing port used by the NXT.  In this case it is COM9.  If it is different, you will need to change the line in the VB program to fix it.
11.  Now run the VB program and click Button1.  If everything worked Label1 will change to Connected.
12.  If it didn't there will be a message box with an error.  Most likely the port number is wrong or the NXT is off.
Part 1. VB and Connecting the NXT with Bluetooth
13. Part 2 you will learn how to read the NXT battery voltage and make it beep.