Re: COMM control refresh
- From: "vbexp" <nobody@xxxxxxx>
- Date: Tue, 25 Oct 2005 19:21:09 -0400
Since you are using the sample I provided earlier, I found that I missed one
line which was supposed to close the port so it can be opened again. Add the
following line:
MSComm1.PortOpen = False
After the following:
> Loop
"Abdhul Saleem" <AbdhulSaleem@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CFAED991-882E-40AC-B510-427270384EEB@xxxxxxxxxxxxxxxx
> Hi,
>
> Is there any way to refresh COMM control without unloading and reloading
> the
> form?
>
> The code snippet currently used is below.
>
> Option Explicit
>
> Private Sub Form_Load()
> 'Debug.Print IsDeviceConnected(1, 0.5) ' Wait up to 0.5 Seconds
> End Sub
>
> ' IsDeviceConnected
> ' INPUT
> ' CommPort CommPort to check. The port must not be already open
> ' TimeOut Time out in seconds to wait for the serial device to come
> online
> ' RETURNS
> ' 0 Timed out. No serial device attached or powered off
> ' 1 Serial device attached and powered on
> ' 2 Error, serial port may be in use
> '
> Private Function IsDeviceConnected(ByVal CommPort As Long, ByVal TimeOut
> As
> Single) As Long
> On Error GoTo ErrorHandler
> Dim t As Single
>
> MSComm1.CommPort = CommPort
> MSComm1.PortOpen = True
> MSComm1.DTREnable = True
>
> t = Timer
> Do While Timer - t < TimeOut
> If t > Timer Then ' Adjust for midnight rollover to 0
> t = t - 86400
> End If
> If MSComm1.DSRHolding Then
> ' Serial device attached and powered on
> IsDeviceConnected = 1 ' Yes
> MSComm1.PortOpen = False
> Exit Function
> End If
> Loop
>
> ' Timed out. No serial device attached or powered off
> IsDeviceConnected = 0 ' No
>
> ExitMe:
> On Error GoTo 0
> Exit Function
> ErrorHandler:
> IsDeviceConnected = 2 ' Error, serial port may be in use
> 'MsgBox "Error " & Err.Number & ": " & Err.Description
> Resume ExitMe
> End Function
>
> Private Sub Timer1_Timer()
> MsgBox IsDeviceConnected(1, 0.5) ' Wait up to 0.5 Seconds
> Unload Me
> Form1.Show
> End Sub
>
>
> Regards,
> M. Abdhul Saleem.
>
.
- References:
- COMM control refresh
- From: Abdhul Saleem
- COMM control refresh
- Prev by Date: Re: Writing to file - CPU usage
- Next by Date: Re: XP Service Packs and Updates effect on VB 6 controls
- Previous by thread: COMM control refresh
- Next by thread: Connection problems SQL
- Index(es):
Relevant Pages
|