|
-
March 7th, 2006, 07:52 AM
#1
Comm Port
hii ,
how to in VIsual Basic programming , what comm ports are available in the computer where application is working,
i want to show in the combo box the available comm ports on the computer,
and allow user to select the comm port.
Very similar to how we select the comm port in Hyperterminal.
yogi
-
March 7th, 2006, 08:01 AM
#2
Re: Comm Port
Hope, you can use the MSCom control to find the comports available on the machine.
thanks
-
March 7th, 2006, 08:25 AM
#3
Re: Comm Port
Hi,
Here is a sample code.....
Code:
Private Sub Combo1_Click()
On Error GoTo ErrHandle
MSComm1.CommPort = Combo1.Text
MSComm1.Settings "9600,N,8,1" 'Where 9600 is the baud rate, N is the parity, 8 is the number of data bits, and 1 is the number of stop bits. The default value of value is: 9600,N,8,1
MSComm1.PortOpen = True
If MSComm1.PortOpen = False Then
MsgBox "com port " & MSComm1.CommPort & " not Opened"
End If
Exit Sub
ErrHandle:
If Err.Number = 8002 Then
MsgBox "Port number " & MSComm1.CommPort & " not available"
End If
End Sub
Private Sub Form_Load()
With Combo1
.AddItem "1", 0
.AddItem "2", 1
.AddItem "3", 2
.AddItem "4", 3
.AddItem "5", 4
.AddItem "6", 5
.AddItem "7", 6
End With
End Sub
Thanks
-
March 8th, 2006, 12:12 AM
#4
Re: Comm Port
hi,
the idea is good but i dont want to list the ones which are not present , only which are present on the computer, so only to select them directly
thanks ,
yogi
-
March 8th, 2006, 09:09 AM
#5
Re: Comm Port
hii gurus,
Please help i am in a deep fix, about this ,
i have to design a combobox very similar to the Hyperterminal combobox where we select the available commport on the respective computer.
pleasssssssssssee help
yogi
-
March 8th, 2006, 09:58 AM
#6
Re: Comm Port
Code:
On Error Resume Next
For I = Min to Max
MSComm1.Port = I
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
If MSComm1.PortOpen and Err.Number = 0 then
Combo1.AddItem I, I - 1
endif
MSComm1.PortOpen = False
Err.Number = 0
Next I
Have not tried, hope it works ;-)
Last edited by jsiii; October 5th, 2006 at 03:18 AM.
-
March 9th, 2006, 12:29 AM
#7
Re: Comm Port
hii guys ,
there is no direct method to get the available commports
its a check and list basis to know the available ports
here is the code
Private Sub MDIForm_Load()
Dim I As Integer
On Error Resume Next
With GPS
If .PortOpen = True Then .PortOpen = False
For I = 1 To 16
.CommPort = I
.PortOpen = True
If err.Number = 0 Then
PortSel.AddItem "Com " & Format$(I)
.PortOpen = False
Else
err.Clear
End If
Next I
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|