VB and BS2
NWUpgrades
Posts: 292
Following Unsoundcode's Info at this site, http://forums.parallax.com/showthread.php?p=671804·I am able to get my BS2 to work with VB 2008 Express. Now the question is this: Is it possible to insert other "buttons" within this program to make a sound or LED to light up? I have a piezo speaker on IN4, but I am not sure of the code needed to make it work from within VB, or if it is even possible. Thanks if you can help.
Comments
Did you figure out how to select different baud rates?
Jeff T.
SerialPort1.BaudRate="4800"
The original template added the flexibility of allowing the user to select a baud rate. I used a combo box with certain baudrates pre-written in the "Collection" property of the combo box which when selected is passed to the serial port
SerialPort1.BaudRate=ComboBox1.SelectedItem
The port must be closed when selecting the baud.
Jeff T.
After you have typed Comms double click the text and it will open Code View and insert the PortToolStripMenuItem_Click
After inserting Form2show() and running it, Form 1 comes up. Any ideas of what I am doing wrong?
Here is what comes up:
Public Class Form1
Private Sub CommsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CommsToolStripMenuItem.Click
Form2.Show()
End Sub
End Class
If I remember I did make a mistake with the way I wrote that up originally but didn't think it was too far out to be an issue.
Try the VB help file for menu items.
Jeff T.
ComboBox2.Items.Add(2400)
ComboBox2.Items.Add(4800)
ComboBox2.Items.Add(9600)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each portName As String In My.Computer.Ports.SerialPortNames
ComboBox1.Items.Add(portName)
Next
If Not _port.IsOpen Then
Button2.Enabled = False
ComboBox1.Text = ComboBox1.Items(0)
ComboBox2.Text = ComboBox2.Items(0)
Else
Button1.Enabled = False
ComboBox1.Text = _port.PortName
ComboBox2.Text = _port.BaudRate
End If
End Sub
End Class
Before writing the code for Form2 all the controls should be placed on the form in designer view·, thats something like 3 buttons and 2 combo boxes. If you do that , making sure the comboboxes are named Combobox1 and Combobox2·, that should clear the errors.
The code for the comboboxes is written in the Form2 load event
Jeff T.