?? portsettings.vb
字號:
Public Class PortSettings
Sub InitializePortSettings()
' Purpose : set initial port parameters.
Dim BitRates(10) As Integer
Dim Count As Integer
'Bit rates to select from.
BitRates(0) = 300
BitRates(1) = 600
BitRates(2) = 1200
BitRates(3) = 2400
BitRates(4) = 9600
BitRates(5) = 14400
BitRates(6) = 19200
BitRates(7) = 38400
BitRates(8) = 57600
BitRates(9) = 115200
BitRates(10) = 128000
'Place the bit rates in the combobox.
For Count = 0 To UBound(BitRates)
cmbBitRate.Items.Add(CStr(BitRates(Count)))
Next Count
'Find available COM ports.
DisplayComPorts()
' Select a default COM port and bit rate.
' You can change the default port here
' or use My.Computer.Registry Object or VB's SetSetting/GetSetting to save preferences.
cmbPort.SelectedIndex = 0
cmbBitRate.SelectedIndex = 4
MainForm.selectedPortIndex = 0
'In the bit-rate combobox, set the bit rate for the selected port.
Do Until _
(cmbBitRate.Text = CStr(myComPorts(MainForm.SelectedPortIndex).BitRate)) Or _
(cmbBitRate.SelectedIndex = cmbBitRate.Items.Count - 1)
cmbBitRate.SelectedIndex = cmbBitRate.SelectedIndex + 1
Loop
End Sub
Sub DisplayComPorts()
' Purpose : find available COM ports and display them in a combobox.
Dim ComPortIndex As Integer = 0
Dim ComPortsArray(15) As String
FindComPorts()
' Clear the combobox and repopulate it (in case ports have been added or removed).
cmbPort.Items.Clear()
For ComPortIndex = 0 To UBound(myComPorts)
If myComPorts(ComPortIndex).PortName <> "" Then
'Place the name of the port in the combobox.
cmbPort.Items.Add(myComPorts(ComPortIndex).PortName)
End If
Next
End Sub
Friend Sub PortSettings_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
myPortSettings = Me
InitializePortSettings()
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
' Save the previous selected port index so we can close the port if needed.
MainForm.previousPortIndex = MainForm.selectedPortIndex
' Save the new selected port index.
MainForm.selectedPortIndex = cmbPort.SelectedIndex
' Currently supports USBwiz default of 9600 bps only.
' To do: add support for USBwiz BR command to change baud rate.
MainForm.portChange = True
Me.Hide()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Hide()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -