locked
USB Devices RRS feed

  • Question

  • I am looking for code samples for connecting to a device that has a USB connection. I want to scan the USB ports to find all of the devices, then find a specific device. Once there, I want to establish a communication session with the device. The device I am trying to connect to is a group of printers that my company services. These devices are from different manufacturers, but I need to be able from within my VB .Net application to select the port the device is connected to, then verify that the port is working. Next I need to send strings to the devices to configure them, print from them, and generally interact with them. Any methods or code samples would be appreciated.

     

    I do realize that the manufacturers supply the Dll's and drivers for these types of devices, but what I want is an idea as to the general structure of the code I am trying to write. From there I intend to build specific code for each device.

     

    Thank you.

     

    Phill Goin

     

    Tuesday, January 1, 2008 11:16 PM

Answers

  •  Coder24.com wrote:

    Hi! Use the following designer for the windows application.

     

    Code Block

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

    Partial Class Form1

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)

    If disposing AndAlso components IsNot Nothing Then

    components.Dispose()

    End If

    MyBase.Dispose(disposing)

    End Sub

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer.

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

    Me.Label1 = New System.Windows.Forms.Label

    Me.cbbCOMPorts = New System.Windows.Forms.ComboBox

    Me.txtDataToSend = New System.Windows.Forms.TextBox

    Me.btnSend = New System.Windows.Forms.Button

    Me.lblMessage = New System.Windows.Forms.Label

    Me.btnConnect = New System.Windows.Forms.Button

    Me.btnDisconnect = New System.Windows.Forms.Button

    Me.txtDataReceived = New System.Windows.Forms.RichTextBox

    Me.txtPhoneNumber = New System.Windows.Forms.TextBox

    Me.Label2 = New System.Windows.Forms.Label

    Me.btnDialNumber = New System.Windows.Forms.Button

    Me.btnAnswerCall = New System.Windows.Forms.Button

    Me.GroupBox1 = New System.Windows.Forms.GroupBox

    Me.GroupBox1.SuspendLayout()

    Me.SuspendLayout()

    '

    'Label1

    '

    Me.Label1.AutoSize = True

    Me.Label1.Location = New System.Drawing.Point(12, 9)

    Me.Label1.Name = "Label1"

    Me.Label1.Size = New System.Drawing.Size(104, 13)

    Me.Label1.TabIndex = 0

    Me.Label1.Text = "Available COM Ports"

    '

    'cbbCOMPorts

    '

    Me.cbbCOMPorts.FormattingEnabled = True

    Me.cbbCOMPorts.Location = New System.Drawing.Point(122, 6)

    Me.cbbCOMPorts.Name = "cbbCOMPorts"

    Me.cbbCOMPorts.Size = New System.Drawing.Size(80, 21)

    Me.cbbCOMPorts.TabIndex = 1

    '

    'txtDataToSend

    '

    Me.txtDataToSend.Location = New System.Drawing.Point(12, 236)

    Me.txtDataToSend.Multiline = True

    Me.txtDataToSend.Name = "txtDataToSend"

    Me.txtDataToSend.Size = New System.Drawing.Size(273, 47)

    Me.txtDataToSend.TabIndex = 2

    '

    'btnSend

    '

    Me.btnSend.Location = New System.Drawing.Point(289, 260)

    Me.btnSend.Name = "btnSend"

    Me.btnSend.Size = New System.Drawing.Size(75, 23)

    Me.btnSend.TabIndex = 3

    Me.btnSend.Text = "Send"

    Me.btnSend.UseVisualStyleBackColor = True

    '

    'lblMessage

    '

    Me.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

    Me.lblMessage.Location = New System.Drawing.Point(12, 36)

    Me.lblMessage.Name = "lblMessage"

    Me.lblMessage.Size = New System.Drawing.Size(352, 23)

    Me.lblMessage.TabIndex = 5

    '

    'btnConnect

    '

    Me.btnConnect.Location = New System.Drawing.Point(210, 4)

    Me.btnConnect.Name = "btnConnect"

    Me.btnConnect.Size = New System.Drawing.Size(75, 23)

    Me.btnConnect.TabIndex = 6

    Me.btnConnect.Text = "Connect"

    Me.btnConnect.UseVisualStyleBackColor = True

    '

    'btnDisconnect

    '

    Me.btnDisconnect.Location = New System.Drawing.Point(291, 4)

    Me.btnDisconnect.Name = "btnDisconnect"

    Me.btnDisconnect.Size = New System.Drawing.Size(75, 23)

    Me.btnDisconnect.TabIndex = 7

    Me.btnDisconnect.Text = "Disconnect"

    Me.btnDisconnect.UseVisualStyleBackColor = True

    '

    'txtDataReceived

    '

    Me.txtDataReceived.Location = New System.Drawing.Point(12, 62)

    Me.txtDataReceived.Name = "txtDataReceived"

    Me.txtDataReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical

    Me.txtDataReceived.Size = New System.Drawing.Size(352, 168)

    Me.txtDataReceived.TabIndex = 8

    Me.txtDataReceived.Text = ""

    '

    'txtPhoneNumber

    '

    Me.txtPhoneNumber.Location = New System.Drawing.Point(85, 19)

    Me.txtPhoneNumber.Name = "txtPhoneNumber"

    Me.txtPhoneNumber.Size = New System.Drawing.Size(99, 20)

    Me.txtPhoneNumber.TabIndex = 9

    '

    'Label2

    '

    Me.Label2.AutoSize = True

    Me.Label2.Location = New System.Drawing.Point(6, 22)

    Me.Label2.Name = "Label2"

    Me.Label2.Size = New System.Drawing.Size(78, 13)

    Me.Label2.TabIndex = 10

    Me.Label2.Text = "Phone Number"

    '

    'btnDialNumber

    '

    Me.btnDialNumber.Location = New System.Drawing.Point(190, 17)

    Me.btnDialNumber.Name = "btnDialNumber"

    Me.btnDialNumber.Size = New System.Drawing.Size(75, 23)

    Me.btnDialNumber.TabIndex = 11

    Me.btnDialNumber.Text = "Dial Number"

    Me.btnDialNumber.UseVisualStyleBackColor = True

    '

    'btnAnswerCall

    '

    Me.btnAnswerCall.Location = New System.Drawing.Point(271, 17)

    Me.btnAnswerCall.Name = "btnAnswerCall"

    Me.btnAnswerCall.Size = New System.Drawing.Size(75, 23)

    Me.btnAnswerCall.TabIndex = 12

    Me.btnAnswerCall.Text = "Answer Call"

    Me.btnAnswerCall.UseVisualStyleBackColor = True

    '

    'GroupBox1

    '

    Me.GroupBox1.Controls.Add(Me.Label2)

    Me.GroupBox1.Controls.Add(Me.btnAnswerCall)

    Me.GroupBox1.Controls.Add(Me.txtPhoneNumber)

    Me.GroupBox1.Controls.Add(Me.btnDialNumber)

    Me.GroupBox1.Location = New System.Drawing.Point(12, 289)

    Me.GroupBox1.Name = "GroupBox1"

    Me.GroupBox1.Size = New System.Drawing.Size(352, 50)

    Me.GroupBox1.TabIndex = 13

    Me.GroupBox1.TabStop = False

    Me.GroupBox1.Text = "Bluetooth Handset"

    '

    'Form1

    '

    Me.AcceptButton = Me.btnSend

    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

    Me.BackColor = System.Drawing.Color.White

    Me.ClientSize = New System.Drawing.Size(379, 351)

    Me.Controls.Add(Me.GroupBox1)

    Me.Controls.Add(Me.txtDataReceived)

    Me.Controls.Add(Me.btnDisconnect)

    Me.Controls.Add(Me.btnConnect)

    Me.Controls.Add(Me.lblMessage)

    Me.Controls.Add(Me.btnSend)

    Me.Controls.Add(Me.txtDataToSend)

    Me.Controls.Add(Me.cbbCOMPorts)

    Me.Controls.Add(Me.Label1)

    Me.Name = "Form1"

    Me.Text = "Form1"

    Me.GroupBox1.ResumeLayout(False)

    Me.GroupBox1.PerformLayout()

    Me.ResumeLayout(False)

    Me.PerformLayout()

    End Sub

    Friend WithEvents Label1 As System.Windows.Forms.Label

    Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox

    Friend WithEvents txtDataToSend As System.Windows.Forms.TextBox

    Friend WithEvents btnSend As System.Windows.Forms.Button

    Friend WithEvents lblMessage As System.Windows.Forms.Label

    Friend WithEvents btnConnect As System.Windows.Forms.Button

    Friend WithEvents btnDisconnect As System.Windows.Forms.Button

    Friend WithEvents txtDataReceived As System.Windows.Forms.RichTextBox

    Friend WithEvents txtPhoneNumber As System.Windows.Forms.TextBox

    Friend WithEvents Label2 As System.Windows.Forms.Label

    Friend WithEvents btnDialNumber As System.Windows.Forms.Button

    Friend WithEvents btnAnswerCall As System.Windows.Forms.Button

    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox

    End Class

     

     

    Use the following designer on the code..

     

    The following code, is from my early application so i copy it, it's why you could see a label with the text = "phone number", but you could change that if you whant.

    Wednesday, January 2, 2008 2:34 PM

All replies

  • Hi!

     

    You could maybe test this type of code:

    Code Block

    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

    cbbCOMPorts.Items.Add( _

    My.Computer.Ports.SerialPortNames(i))

    Next

    btnDisconnect.Enabled = False

    End Sub

    Private Sub DataReceived( _

    ByVal sender As Object, _

    ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _

    Handles serialPort.DataReceived

    txtDataReceived.Invoke(New _

    myDelegate(AddressOf updateTextBox), _

    New Object() {})

    End Sub

    Private Sub btnSend_Click( _

    ByVal sender As System.Object, _

    ByVal e As System.EventArgs) _

    Handles btnSend.Click

    Try

    serialPort.Write(txtDataToSend.Text & vbCrLf)

    With txtDataReceived

    .SelectionColor = Color.Black

    .AppendText(txtDataToSend.Text & vbCrLf)

    .ScrollToCaret()

    End With

    txtDataToSend.Text = String.Empty

    Catch ex As Exception

    MsgBox(ex.ToString)

    End Try

    End Sub

    Public Delegate Sub myDelegate()

    Public Sub updateTextBox()

    With txtDataReceived

    .Font = New Font("Garamond", 12.0!, FontStyle.Bold)

    .SelectionColor = Color.Red

    .AppendText(serialPort.ReadExisting)

    .ScrollToCaret()

    End With

    End Sub

    Private Sub btnConnect_Click( _

    ByVal sender As System.Object, _

    ByVal e As System.EventArgs) _

    Handles btnConnect.Click

    If serialPort.IsOpen Then

    serialPort.Close()

    End If

    Try

    With serialPort

    .PortName = cbbCOMPorts.Text

    .BaudRate = 96000

    .Parity = IO.Ports.Parity.None

    .DataBits = 8

    .StopBits = IO.Ports.StopBits.One

    ' .Encoding = System.Text.Encoding.Unicode

    End With

    serialPort.Open()

    lblMessage.Text = cbbCOMPorts.Text & " connected."

    btnConnect.Enabled = False

    btnDisconnect.Enabled = True

    Catch ex As Exception

    MsgBox(ex.ToString)

    End Try

    End Sub

    Private Sub btnDisconnect_Click( _

    ByVal sender As System.Object, _

    ByVal e As System.EventArgs) _

    Handles btnDisconnect.Click

    Try

    serialPort.Close()

    lblMessage.Text = serialPort.PortName & " disconnected."

    btnConnect.Enabled = True

    btnDisconnect.Enabled = False

    Catch ex As Exception

    MsgBox(ex.ToString)

    End Try

    End Sub

    Private Sub btnDialNumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDialNumber.Click

    serialPort.Write("ATDT " & txtPhoneNumber.Text & vbCrLf)

    End Sub

    Private Sub btnAnswerCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswerCall.Click

    serialPort.Write("AT*EVA" & vbCrLf)

    End Sub

    End Class

     

     

    You could test it. pleas replay!

    Wednesday, January 2, 2008 2:26 PM
  • Hi! Use the following designer for the windows application.

     

    Code Block

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

    Partial Class Form1

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)

    If disposing AndAlso components IsNot Nothing Then

    components.Dispose()

    End If

    MyBase.Dispose(disposing)

    End Sub

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer.

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

    Me.Label1 = New System.Windows.Forms.Label

    Me.cbbCOMPorts = New System.Windows.Forms.ComboBox

    Me.txtDataToSend = New System.Windows.Forms.TextBox

    Me.btnSend = New System.Windows.Forms.Button

    Me.lblMessage = New System.Windows.Forms.Label

    Me.btnConnect = New System.Windows.Forms.Button

    Me.btnDisconnect = New System.Windows.Forms.Button

    Me.txtDataReceived = New System.Windows.Forms.RichTextBox

    Me.txtPhoneNumber = New System.Windows.Forms.TextBox

    Me.Label2 = New System.Windows.Forms.Label

    Me.btnDialNumber = New System.Windows.Forms.Button

    Me.btnAnswerCall = New System.Windows.Forms.Button

    Me.GroupBox1 = New System.Windows.Forms.GroupBox

    Me.GroupBox1.SuspendLayout()

    Me.SuspendLayout()

    '

    'Label1

    '

    Me.Label1.AutoSize = True

    Me.Label1.Location = New System.Drawing.Point(12, 9)

    Me.Label1.Name = "Label1"

    Me.Label1.Size = New System.Drawing.Size(104, 13)

    Me.Label1.TabIndex = 0

    Me.Label1.Text = "Available COM Ports"

    '

    'cbbCOMPorts

    '

    Me.cbbCOMPorts.FormattingEnabled = True

    Me.cbbCOMPorts.Location = New System.Drawing.Point(122, 6)

    Me.cbbCOMPorts.Name = "cbbCOMPorts"

    Me.cbbCOMPorts.Size = New System.Drawing.Size(80, 21)

    Me.cbbCOMPorts.TabIndex = 1

    '

    'txtDataToSend

    '

    Me.txtDataToSend.Location = New System.Drawing.Point(12, 236)

    Me.txtDataToSend.Multiline = True

    Me.txtDataToSend.Name = "txtDataToSend"

    Me.txtDataToSend.Size = New System.Drawing.Size(273, 47)

    Me.txtDataToSend.TabIndex = 2

    '

    'btnSend

    '

    Me.btnSend.Location = New System.Drawing.Point(289, 260)

    Me.btnSend.Name = "btnSend"

    Me.btnSend.Size = New System.Drawing.Size(75, 23)

    Me.btnSend.TabIndex = 3

    Me.btnSend.Text = "Send"

    Me.btnSend.UseVisualStyleBackColor = True

    '

    'lblMessage

    '

    Me.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

    Me.lblMessage.Location = New System.Drawing.Point(12, 36)

    Me.lblMessage.Name = "lblMessage"

    Me.lblMessage.Size = New System.Drawing.Size(352, 23)

    Me.lblMessage.TabIndex = 5

    '

    'btnConnect

    '

    Me.btnConnect.Location = New System.Drawing.Point(210, 4)

    Me.btnConnect.Name = "btnConnect"

    Me.btnConnect.Size = New System.Drawing.Size(75, 23)

    Me.btnConnect.TabIndex = 6

    Me.btnConnect.Text = "Connect"

    Me.btnConnect.UseVisualStyleBackColor = True

    '

    'btnDisconnect

    '

    Me.btnDisconnect.Location = New System.Drawing.Point(291, 4)

    Me.btnDisconnect.Name = "btnDisconnect"

    Me.btnDisconnect.Size = New System.Drawing.Size(75, 23)

    Me.btnDisconnect.TabIndex = 7

    Me.btnDisconnect.Text = "Disconnect"

    Me.btnDisconnect.UseVisualStyleBackColor = True

    '

    'txtDataReceived

    '

    Me.txtDataReceived.Location = New System.Drawing.Point(12, 62)

    Me.txtDataReceived.Name = "txtDataReceived"

    Me.txtDataReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical

    Me.txtDataReceived.Size = New System.Drawing.Size(352, 168)

    Me.txtDataReceived.TabIndex = 8

    Me.txtDataReceived.Text = ""

    '

    'txtPhoneNumber

    '

    Me.txtPhoneNumber.Location = New System.Drawing.Point(85, 19)

    Me.txtPhoneNumber.Name = "txtPhoneNumber"

    Me.txtPhoneNumber.Size = New System.Drawing.Size(99, 20)

    Me.txtPhoneNumber.TabIndex = 9

    '

    'Label2

    '

    Me.Label2.AutoSize = True

    Me.Label2.Location = New System.Drawing.Point(6, 22)

    Me.Label2.Name = "Label2"

    Me.Label2.Size = New System.Drawing.Size(78, 13)

    Me.Label2.TabIndex = 10

    Me.Label2.Text = "Phone Number"

    '

    'btnDialNumber

    '

    Me.btnDialNumber.Location = New System.Drawing.Point(190, 17)

    Me.btnDialNumber.Name = "btnDialNumber"

    Me.btnDialNumber.Size = New System.Drawing.Size(75, 23)

    Me.btnDialNumber.TabIndex = 11

    Me.btnDialNumber.Text = "Dial Number"

    Me.btnDialNumber.UseVisualStyleBackColor = True

    '

    'btnAnswerCall

    '

    Me.btnAnswerCall.Location = New System.Drawing.Point(271, 17)

    Me.btnAnswerCall.Name = "btnAnswerCall"

    Me.btnAnswerCall.Size = New System.Drawing.Size(75, 23)

    Me.btnAnswerCall.TabIndex = 12

    Me.btnAnswerCall.Text = "Answer Call"

    Me.btnAnswerCall.UseVisualStyleBackColor = True

    '

    'GroupBox1

    '

    Me.GroupBox1.Controls.Add(Me.Label2)

    Me.GroupBox1.Controls.Add(Me.btnAnswerCall)

    Me.GroupBox1.Controls.Add(Me.txtPhoneNumber)

    Me.GroupBox1.Controls.Add(Me.btnDialNumber)

    Me.GroupBox1.Location = New System.Drawing.Point(12, 289)

    Me.GroupBox1.Name = "GroupBox1"

    Me.GroupBox1.Size = New System.Drawing.Size(352, 50)

    Me.GroupBox1.TabIndex = 13

    Me.GroupBox1.TabStop = False

    Me.GroupBox1.Text = "Bluetooth Handset"

    '

    'Form1

    '

    Me.AcceptButton = Me.btnSend

    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

    Me.BackColor = System.Drawing.Color.White

    Me.ClientSize = New System.Drawing.Size(379, 351)

    Me.Controls.Add(Me.GroupBox1)

    Me.Controls.Add(Me.txtDataReceived)

    Me.Controls.Add(Me.btnDisconnect)

    Me.Controls.Add(Me.btnConnect)

    Me.Controls.Add(Me.lblMessage)

    Me.Controls.Add(Me.btnSend)

    Me.Controls.Add(Me.txtDataToSend)

    Me.Controls.Add(Me.cbbCOMPorts)

    Me.Controls.Add(Me.Label1)

    Me.Name = "Form1"

    Me.Text = "Form1"

    Me.GroupBox1.ResumeLayout(False)

    Me.GroupBox1.PerformLayout()

    Me.ResumeLayout(False)

    Me.PerformLayout()

    End Sub

    Friend WithEvents Label1 As System.Windows.Forms.Label

    Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox

    Friend WithEvents txtDataToSend As System.Windows.Forms.TextBox

    Friend WithEvents btnSend As System.Windows.Forms.Button

    Friend WithEvents lblMessage As System.Windows.Forms.Label

    Friend WithEvents btnConnect As System.Windows.Forms.Button

    Friend WithEvents btnDisconnect As System.Windows.Forms.Button

    Friend WithEvents txtDataReceived As System.Windows.Forms.RichTextBox

    Friend WithEvents txtPhoneNumber As System.Windows.Forms.TextBox

    Friend WithEvents Label2 As System.Windows.Forms.Label

    Friend WithEvents btnDialNumber As System.Windows.Forms.Button

    Friend WithEvents btnAnswerCall As System.Windows.Forms.Button

    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox

    End Class

     

     

    Use the following designer on the code..
    Wednesday, January 2, 2008 2:28 PM
  • Hi! What do you mean with "Company Services",

     

    is it that the company is having it's own newtork system where all the employees are using the printers. 

    Wednesday, January 2, 2008 2:31 PM
  •  Coder24.com wrote:

    Hi! Use the following designer for the windows application.

     

    Code Block

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

    Partial Class Form1

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)

    If disposing AndAlso components IsNot Nothing Then

    components.Dispose()

    End If

    MyBase.Dispose(disposing)

    End Sub

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer.

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

    Me.Label1 = New System.Windows.Forms.Label

    Me.cbbCOMPorts = New System.Windows.Forms.ComboBox

    Me.txtDataToSend = New System.Windows.Forms.TextBox

    Me.btnSend = New System.Windows.Forms.Button

    Me.lblMessage = New System.Windows.Forms.Label

    Me.btnConnect = New System.Windows.Forms.Button

    Me.btnDisconnect = New System.Windows.Forms.Button

    Me.txtDataReceived = New System.Windows.Forms.RichTextBox

    Me.txtPhoneNumber = New System.Windows.Forms.TextBox

    Me.Label2 = New System.Windows.Forms.Label

    Me.btnDialNumber = New System.Windows.Forms.Button

    Me.btnAnswerCall = New System.Windows.Forms.Button

    Me.GroupBox1 = New System.Windows.Forms.GroupBox

    Me.GroupBox1.SuspendLayout()

    Me.SuspendLayout()

    '

    'Label1

    '

    Me.Label1.AutoSize = True

    Me.Label1.Location = New System.Drawing.Point(12, 9)

    Me.Label1.Name = "Label1"

    Me.Label1.Size = New System.Drawing.Size(104, 13)

    Me.Label1.TabIndex = 0

    Me.Label1.Text = "Available COM Ports"

    '

    'cbbCOMPorts

    '

    Me.cbbCOMPorts.FormattingEnabled = True

    Me.cbbCOMPorts.Location = New System.Drawing.Point(122, 6)

    Me.cbbCOMPorts.Name = "cbbCOMPorts"

    Me.cbbCOMPorts.Size = New System.Drawing.Size(80, 21)

    Me.cbbCOMPorts.TabIndex = 1

    '

    'txtDataToSend

    '

    Me.txtDataToSend.Location = New System.Drawing.Point(12, 236)

    Me.txtDataToSend.Multiline = True

    Me.txtDataToSend.Name = "txtDataToSend"

    Me.txtDataToSend.Size = New System.Drawing.Size(273, 47)

    Me.txtDataToSend.TabIndex = 2

    '

    'btnSend

    '

    Me.btnSend.Location = New System.Drawing.Point(289, 260)

    Me.btnSend.Name = "btnSend"

    Me.btnSend.Size = New System.Drawing.Size(75, 23)

    Me.btnSend.TabIndex = 3

    Me.btnSend.Text = "Send"

    Me.btnSend.UseVisualStyleBackColor = True

    '

    'lblMessage

    '

    Me.lblMessage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

    Me.lblMessage.Location = New System.Drawing.Point(12, 36)

    Me.lblMessage.Name = "lblMessage"

    Me.lblMessage.Size = New System.Drawing.Size(352, 23)

    Me.lblMessage.TabIndex = 5

    '

    'btnConnect

    '

    Me.btnConnect.Location = New System.Drawing.Point(210, 4)

    Me.btnConnect.Name = "btnConnect"

    Me.btnConnect.Size = New System.Drawing.Size(75, 23)

    Me.btnConnect.TabIndex = 6

    Me.btnConnect.Text = "Connect"

    Me.btnConnect.UseVisualStyleBackColor = True

    '

    'btnDisconnect

    '

    Me.btnDisconnect.Location = New System.Drawing.Point(291, 4)

    Me.btnDisconnect.Name = "btnDisconnect"

    Me.btnDisconnect.Size = New System.Drawing.Size(75, 23)

    Me.btnDisconnect.TabIndex = 7

    Me.btnDisconnect.Text = "Disconnect"

    Me.btnDisconnect.UseVisualStyleBackColor = True

    '

    'txtDataReceived

    '

    Me.txtDataReceived.Location = New System.Drawing.Point(12, 62)

    Me.txtDataReceived.Name = "txtDataReceived"

    Me.txtDataReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical

    Me.txtDataReceived.Size = New System.Drawing.Size(352, 168)

    Me.txtDataReceived.TabIndex = 8

    Me.txtDataReceived.Text = ""

    '

    'txtPhoneNumber

    '

    Me.txtPhoneNumber.Location = New System.Drawing.Point(85, 19)

    Me.txtPhoneNumber.Name = "txtPhoneNumber"

    Me.txtPhoneNumber.Size = New System.Drawing.Size(99, 20)

    Me.txtPhoneNumber.TabIndex = 9

    '

    'Label2

    '

    Me.Label2.AutoSize = True

    Me.Label2.Location = New System.Drawing.Point(6, 22)

    Me.Label2.Name = "Label2"

    Me.Label2.Size = New System.Drawing.Size(78, 13)

    Me.Label2.TabIndex = 10

    Me.Label2.Text = "Phone Number"

    '

    'btnDialNumber

    '

    Me.btnDialNumber.Location = New System.Drawing.Point(190, 17)

    Me.btnDialNumber.Name = "btnDialNumber"

    Me.btnDialNumber.Size = New System.Drawing.Size(75, 23)

    Me.btnDialNumber.TabIndex = 11

    Me.btnDialNumber.Text = "Dial Number"

    Me.btnDialNumber.UseVisualStyleBackColor = True

    '

    'btnAnswerCall

    '

    Me.btnAnswerCall.Location = New System.Drawing.Point(271, 17)

    Me.btnAnswerCall.Name = "btnAnswerCall"

    Me.btnAnswerCall.Size = New System.Drawing.Size(75, 23)

    Me.btnAnswerCall.TabIndex = 12

    Me.btnAnswerCall.Text = "Answer Call"

    Me.btnAnswerCall.UseVisualStyleBackColor = True

    '

    'GroupBox1

    '

    Me.GroupBox1.Controls.Add(Me.Label2)

    Me.GroupBox1.Controls.Add(Me.btnAnswerCall)

    Me.GroupBox1.Controls.Add(Me.txtPhoneNumber)

    Me.GroupBox1.Controls.Add(Me.btnDialNumber)

    Me.GroupBox1.Location = New System.Drawing.Point(12, 289)

    Me.GroupBox1.Name = "GroupBox1"

    Me.GroupBox1.Size = New System.Drawing.Size(352, 50)

    Me.GroupBox1.TabIndex = 13

    Me.GroupBox1.TabStop = False

    Me.GroupBox1.Text = "Bluetooth Handset"

    '

    'Form1

    '

    Me.AcceptButton = Me.btnSend

    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

    Me.BackColor = System.Drawing.Color.White

    Me.ClientSize = New System.Drawing.Size(379, 351)

    Me.Controls.Add(Me.GroupBox1)

    Me.Controls.Add(Me.txtDataReceived)

    Me.Controls.Add(Me.btnDisconnect)

    Me.Controls.Add(Me.btnConnect)

    Me.Controls.Add(Me.lblMessage)

    Me.Controls.Add(Me.btnSend)

    Me.Controls.Add(Me.txtDataToSend)

    Me.Controls.Add(Me.cbbCOMPorts)

    Me.Controls.Add(Me.Label1)

    Me.Name = "Form1"

    Me.Text = "Form1"

    Me.GroupBox1.ResumeLayout(False)

    Me.GroupBox1.PerformLayout()

    Me.ResumeLayout(False)

    Me.PerformLayout()

    End Sub

    Friend WithEvents Label1 As System.Windows.Forms.Label

    Friend WithEvents cbbCOMPorts As System.Windows.Forms.ComboBox

    Friend WithEvents txtDataToSend As System.Windows.Forms.TextBox

    Friend WithEvents btnSend As System.Windows.Forms.Button

    Friend WithEvents lblMessage As System.Windows.Forms.Label

    Friend WithEvents btnConnect As System.Windows.Forms.Button

    Friend WithEvents btnDisconnect As System.Windows.Forms.Button

    Friend WithEvents txtDataReceived As System.Windows.Forms.RichTextBox

    Friend WithEvents txtPhoneNumber As System.Windows.Forms.TextBox

    Friend WithEvents Label2 As System.Windows.Forms.Label

    Friend WithEvents btnDialNumber As System.Windows.Forms.Button

    Friend WithEvents btnAnswerCall As System.Windows.Forms.Button

    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox

    End Class

     

     

    Use the following designer on the code..

     

    The following code, is from my early application so i copy it, it's why you could see a label with the text = "phone number", but you could change that if you whant.

    Wednesday, January 2, 2008 2:34 PM